|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objecteos.io.grapher.Grapher
public class Grapher
The Grapher plots XY-graphs and XY-deviation-graphs. 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 Grapher. See
Grapher(String title, String yAxisName)
.
3. Add data series to the graph. A maximum of 6 series are allowed. See
addSeries(String seriesName, String fileName, int col)
and
addDevSeries(String seriesName, 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 | |
---|---|
Grapher(String title,
String yAxisName)
Create a new Grapher. |
Method Summary | |
---|---|
void |
addDevSeries(String seriesName,
String fileName)
Add a deviation data series to the graph. |
void |
addDevSeries(String seriesName,
String fileName,
int col,
int lowCol,
int highCol)
Add a deviation data series to the graph. |
void |
addSeries(String seriesName,
String fileName)
Add a data series to the graph. |
void |
addSeries(String seriesName,
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 |
---|
public Grapher(String title, String yAxisName)
title
- title of the graph
yAxisName
- y-axis name; the x-axis is the time stepMethod Detail |
---|
public void addSeries(String seriesName, String fileName, int col)
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 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 necessity price printer set up and has produced an output file. You can add a necessity price series to Grapher priceGrapher by calling
priceGrapher.addSeries("necessity price", nPricePrinter.getFileName());
seriesName
- name of the series
fileName
- name of the input file
col
- column that contains the series, column number starts from 0.
If col is omitted, it will be taken to be 1.public void addSeries(String seriesName, String fileName)
addSeries(String seriesName, String fileName, int col)
public void addDevSeries(String seriesName, String fileName, int col, int lowCol, int highCol)
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.
seriesName
- name of the series
fileName
- name of the input file
col
- column number of the average values
lowCol
- column number of the lower bounds
highCol
- column number of the upper bounds
public void addDevSeries(String seriesName, String fileName)
addDevSeries(String seriesName, String fileName, int col, int lowCol, int highCol)
public void plot()
public void export(String fileName)
fileName
- name of the file
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |