eos.io.grapher
Class MultiAxisGrapher

Object
  extended by eos.io.grapher.MultiAxisGrapher

public class MultiAxisGrapher
extends Object

The MultiAxisGrapher plots each data series on a difference axis. This allows plotting of different types of data (e.g. price and trade volume) on the same graph. To use it:

1. Prepare input files. The first line of the file must be the column titles. Column 0 (the first column) must be the time step. All entries must be comma delimited with no space. Here is a sample input:

Step,nPrice
0,0.30
5,0.36
10,0.47
15,0.62
20,0.79
25,0.97
30,1.14
35,1.29
40,1.25
45,1.18

The easiest way to generate input files is to use the Printers.

2. Create a new MultiAxisGrapher. See MultiAxisGrapher(String title).

3. Add data series to the graph. A maximum of 4 series are allowed. See addSeries(String seriesName, String yAxisName, String fileName, int col) and addDevSeries(String seriesName, String yAxisName, String fileName, int col, int lowCol, int highCol).

4. Either use plot() to show the plot in a pop-up window or use export(String fileName) to export it to a PNG file.

For export(), if you omit the file name or provide a simple file name, the file will be saved in a folder called "output". If on the other hand, you specify a directory in the file name, the file will be saved in your specified directory.


Constructor Summary
MultiAxisGrapher(String title)
          Create a new MultiAxisGrapher
 
Method Summary
 void addDevSeries(String seriesName, String yAxisName, String fileName)
          Add a deviation data series to the graph.
 void addDevSeries(String seriesName, String yAxisName, String fileName, int col, int lowCol, int highCol)
          Add a deviation data series to the graph.
 void addSeries(String seriesName, String yAxisName, String fileName)
          Add a data series to the graph.
 void addSeries(String seriesName, String yAxisName, String fileName, int col)
          Add a data series to the graph.
 void export(String fileName)
          Export the graph to a PNG file
 void plot()
          Plot the graph in a pop-up window, with zooming tools
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiAxisGrapher

public MultiAxisGrapher(String title)
Create a new MultiAxisGrapher

Parameters:
title - title of the graph
Method Detail

addSeries

public void addSeries(String seriesName,
                      String yAxisName,
                      String fileName,
                      int col)
Add a data series to the graph. Entries in the input must be comma delimited (with no space). The first line must be the column titles. Column 0 (the first column) must be the time step. By default, data are assumed to be in column 1. If not, you need to specify the column number. Here is a sample input:

Step,Food_Price
0,0.30
5,0.36
10,0.47
15,0.62
20,0.79
25,0.97
30,1.14
35,1.29
40,1.25
45,1.18

The easiest way to prepare input files is to use the Printers provided. All Printers have a getFileName() method, which you may call to get the file name. Multi-column Printers (those with flags) have a getCol(int flag) method which you may use to get the column number.

e.g. Say you have food price printer set up and has produced an output file. You can add a food price series to MultiAxisGrapher foodMarketGrapher by calling

foodMarketGrapher.addSeries("Food Price", "Price", foodPricePrinter.getFileName());

Parameters:
seriesName - name of the series

yAxisName - y-axis name

fileName - name of the file that contains the series

col - column that contains the series


addSeries

public void addSeries(String seriesName,
                      String yAxisName,
                      String fileName)
Add a data series to the graph. See addSeries(String seriesName, String yAxisName, String fileName, int col)


addDevSeries

public void addDevSeries(String seriesName,
                         String yAxisName,
                         String fileName,
                         int col,
                         int lowCol,
                         int highCol)
Add a deviation data series to the graph. A deviation series displays a spread around the trend line (see the sample output below).

The input file must have 4 columns. Column 0 (the first column) must be the time step. Column 1 is the trend line (or average line). Column 2 is the lower bound (the bottom edge of the spread). Column 3 is the upper bound (the top edge of the spread). If the these 3 columns are not columns 1, 2, 3, or they are not in this order, you need to specify their column numbers. All entries in the input must be comma delimited (with no space). Here is a sample input:

Step,Avg_SimpleLaborer_Money_Stock,Min_SimpleLaborer_Money_Stock,Max_SimpleLaborer_Money_Stock
0,60.146,60.0,60.975
5,59.778,55.651,64.489
10,58.612,52.729,62.906
15,57.648,50.441,69.807
20,56.754,40.334,69.722
25,56.501,37.882,73.368
30,58.268,36.126,76.568

The easiest way to generate input files is to use the Printers. The StatsPrinter.STD flag is extremely handy. It prints the average, the minimum and the maximum. You may use getFileName() of Printers to get the file name and getCol(int flag) to get the column number.

Parameters:
seriesName - name of the series

yAxisName - y-axis name

fileName - name of the file that contains the series

col - column of the average values

lowCol - column of the lower bounds

highCol - column of the upper bounds


addDevSeries

public void addDevSeries(String seriesName,
                         String yAxisName,
                         String fileName)
Add a deviation data series to the graph. See addDevSeries(String seriesName, String yAxisName, String fileName, int col, int lowCol, int highCol)


plot

public void plot()
Plot the graph in a pop-up window, with zooming tools


export

public void export(String fileName)
Export the graph to a PNG file

Parameters:
fileName - name of the file