Gekko PLOT gallery

In this gallery, PLOT command options are used. Note however, that all these examples could have been produced by means of xml-based schemas (.gpt files) to style the graphs, cf. the code examples below.

The gallery uses .svg files (vector-based). For use in MS Office, .emf files can be used instead. Later on, output types like eps, pdf, latex, etc. will be added (these are supported by gnuplot).

The .gcm command file to auto-generate (with Gekko 2.1.8) the present html page including the graphs is here.

Instead of "PLOT <...> x1 <...>, x2 <...>;", a g.gpt file could store the settings and be called with "PLOT x1, x2 using=g;". The following code shows how to use PLOT options versus a .gpt file. Both produce exactly the same graph (dash type graph, shown later in the examples).

Using PLOT options

plot <type=lines linecolor='blue'> rfy<dashtype='1'>, rfcp<dashtype='2'>, rfm<dashtype='3'>, rfe<dashtype='4'>;

Using .gpt schema file

plot rfy, rfcp, rfm, rfe using=p;

  where p.gpt is the following xml file:

<gekkoplot>
  <type>lines</type>
  <linecolor>blue</linecolor>
  <lines>
    <line>
      <dashtype>1</dashtype>
    </line>
    <line>
      <dashtype>2</dashtype>
    </line>
    <line>
      <dashtype>3</dashtype>
    </line>
    <line>
      <dashtype>4</dashtype>
    </line>
  </lines>
</gekkoplot>

 

Default plot (percent growth rates of GDP/consumption/imports/exports)

plot rfy, rfcp, rfm, rfe;

Mirrored y-axis, grid removed, y=0 axis removed, key (legend) put inside the plot.

plot <ymirror='3' grid=no xzeroaxis=no key='inside vertical bot left Left reverse'> rfy, rfcp, rfm, rfe;

Vertical line at year 2000, and between 2010 and 2011. Horizontal line at y=-10

plot <xlineafter=2010 xline=2000 yline=-10 > rfy, rfcp, rfm, rfe;

Titles, also on y-axis

plot <title='Gekko PLOT' subtitle='With help from gnuplot' ytitle='Percent' ymirror='3'> rfy, rfcp, rfm, rfe;

Variable rfm shown at y2-axis (right-hand side). Variable labels altered.

plot rfy 'GDP', rfcp 'Consumption', rfm 'Imports (right)' <y2>, rfe 'Exports'

Same plot as above, but with y and y2 axis ranges fixed. A y2=0 axis is added. Cf. also the "separate" option in a later example.

plot <ymin=-35 ymax=15 y2min=-15 y2max=35 x2zeroaxis> rfy 'GDP', rfcp 'Consumption', rfm 'Imports (right)' <y2>, rfe 'Exports'

Excel color palette instead

plot <palette='#5B9BD5,#ED7D31,#A5A5A5,#FFC000'>rfy, rfcp, rfm, rfe;

Set colors one by one

plot rfy<linecolor='yellow'>, rfcp<linecolor='orange'>, rfm<linecolor='red'>, rfe<linecolor='gray'>;

Dash types

plot <type=lines linecolor='blue'> rfy<dashtype='1'>, rfcp<dashtype='2'>, rfm<dashtype='3'>, rfe<dashtype='4'>;

Line width

plot <type=lines> rfy<linewidth=3>, rfcp<linewidth=6>, rfm<linewidth=9>, rfe<linewidth=12>;

Point size

plot rfy<pointsize=0.5>, rfcp<pointsize=0.7>, rfm<pointsize=0.8>, rfe<pointsize=1.1>;

Point type

plot <pointsize=0.8> rfy<pointtype='1'>, rfcp<pointtype='2'>, rfm<pointtype='3'>, rfe<pointtype='4'>;

Boxes type (bar/histogram)

plot <2001 2014 type=boxes> rfy;

No fill (empty boxes)

plot <2001 2014 type=boxes fillstyle='empty'> rfy;

A pattern

plot <2001 2014 type=boxes fillstyle='pattern 5'> rfy;

Narrower box width

plot <2001 2014 type=boxes boxwidth=0.375> rfy;

Grouped boxes. The gap between the groups can be set if needed (boxgap).

plot <2001 2014 type=boxes> rfy, rfcp;

Stacked boxes

plot <type=boxes stack> rfy, rfcp, rfm, rfe;

Stacked boxes, 100%. Here it is done manually, later on this will be a feature.

plot <2001 2014 type=boxes stack ymax=100> 100*fy/(fy+fcp+fm+fe), 100*fcp/(fy+fcp+fm+fe), 100*fm/(fy+fcp+fm+fe), 100*fe/(fy+fcp+fm+fe);

Stacked boxes, with patterns. The .svg filetype used here overlaps the boxes: this is not so regarding the .emf or .png terminals. This problem will be addressed.

plot <2001 2014 type=boxes stack> rfy<fillstyle='pattern 1'>, rfcp<fillstyle='pattern 5'>, rfm<fillstyle='pattern 6'>, rfe<fillstyle='pattern 4'>;

Boxes and lines combined

plot rfy<type=boxes>, rfcp, rfm, rfe;

A special Gekko PLOT type: "separated". This type auto-calculates the y and y2 axis ranges, so that the boxes and lines are separated (below and above), where the boxes occupy around 25% of the vertical space. This option is very handy for residual plots, that is, observed/predicted/residuals

plot <separate> rfy<type=boxes>, rfcp, rfm, rfe;

Area curves, stacked

plot <type=filledcurves stack> rfy, rfcp, rfm, rfe;

Area curves, stacked 100%. Here it is done manually, later on this will be a feature

plot <type=filledcurves stack ymax=100> 100*fy/(fy+fcp+fm+fe), 100*fcp/(fy+fcp+fm+fe), 100*fm/(fy+fcp+fm+fe), 100*fe/(fy+fcp+fm+fe);

Steps

plot <type=steps> rfy;

Points

plot <type=points> rfy, rfcp, rfm, rfe;

Impulses

plot <type=impulses> rfy;

Factor 1.0, ymaxhard = 4, ymaxsoft = 2

The following graphs are examples regarding the use of ymax (there is a similar ymin) in the "hard" and "soft" variants. By using these, a lot of manual finetuning can be avoided when producing batches of similar graphs

The graph here is not affected by the range settings (ymaxhard = 4 and ymaxsoft = 2).

plot <linecolor='blue' ymaxhard = 4 ymaxsoft=2> 1.0*rpcp;

Factor 1.5, ymaxhard = 4, ymaxsoft = 2

Data is multiplied with 1.5, some data points above 4 are cut off.

plot <linecolor='blue' ymaxhard = 4 ymaxsoft=2> 1.5*rpcp;

Factor 2.0, ymaxhard = 4, ymaxsoft = 2

Data is multiplied with 2.0, more data points are cut off.

plot <linecolor='blue' ymaxhard = 4 ymaxsoft=2> 2.0*rpcp;

Factor 0.5, ymaxhard = 4, ymaxsoft = 2

Now, data is multiplied with 0.5, note that the y range has a max of 2, even though the data is scaled down. So ymaxsoft will avoid zooming in too much, if the data values become small.

plot <linecolor='blue' ymaxhard = 4 ymaxsoft=2> 0.5*rpcp;

Factor 0.25, ymaxhard = 4, ymaxsoft = 2

The graph keeps the y range max of 2.

To sum up, ymaxhard and yminhard are good for filtering out outliers that the user does not want to be shown.

Whereas ymaxsoft and yminsoft are good for keeping a sensible span of the graph, even if the data values become small. Another way of describing it is that zooming in too much on small data values is avoided, so that graphs with different data values are easier to compare.

plot <linecolor='blue' ymaxhard = 4 ymaxsoft=2> 0.25*rpcp;