! Example with custom legend. ! Author: Francois Tonneau size 14 11 set font ss amove 2 2 begin graph size 8 8 fullsize xaxis min 4.15 max 8.25 dticks 1 yaxis min 1.75 max 4.50 dticks 0.5 ! The axis subcommand, 'grid', converts axis ticks into gridlines. The ! 'labels' command deals with the tick labels of all axes. axis grid color #c8c8c8 labels color black dist 0.3 hei 0.45 xtitle "Sepal length (mm)" dist 0.5 ytitle "Sepal width (mm)" dist 0.5 data "legend.dat" d1=c1,c2 d2=c3,c4 d3=c5,c6 d1 color cadetblue marker fcircle msize 0.25 d2 color indianred marker fcircle msize 0.25 d3 color goldenrod marker fcircle msize 0.25 ! We define new datasets from the linear fit of existing datasets, and we ! plot the results in a low-rank layer to have them behind the actual data ! points: let d4 = linfit d1 from 4.3 to 5.8 let d6 = linfit d3 from 4.9 to 7.9 let d5 = linfit d2 from 4.9 to 7.0 begin layer 300 d4 color cadetblue line lwidth 0.04 d5 color indianred line lwidth 0.04 d6 color goldenrod line lwidth 0.04 end layer end graph set hei 0.45 amove 10.50 8.80 write "Species:" ! In GLE, different 'set' commands can be combined in a single line. Here we ! combine font-height and line-width settings: set hei 0.48 lwidth 0.05 ! We now use a 'begin key ... end key' block to build our plot legend. The first ! line in the block is our global key command. It puts the key (i.e., legend) at ! an absolute location in the figure, prevents GLE from drawing a box around the ! key ('nobox'), and defines line length for all entries ('llen 0.5'). The last ! three commands define a separate key entry with a line, marker, and text. The ! line and marker in each entry will not be superimposed because our global key ! command does not include the 'compact' option (see what happens when you add ! 'compact' after 'llen 0.5'). begin key absolute 10.30 6.55 nobox llen 0.5 ! Another trick: The ampersand (&) can be used anywhere in a GLE script to ! continue a long command on the next line. Also note that we use the {\it ! ...} formatting macro to set text in italics. line lwidth 0.04 color cadetblue marker fcircle msize 0.25 & text "{\it setosa}" line lwidth 0.04 color indianred marker fcircle msize 0.25 & text "{\it versicolor}" line lwidth 0.04 color goldenrod marker fcircle msize 0.25 & text "{\it virginica}" end key ! Done. We have learned about 'begin key ... end key' blocks and about linear ! fitting.