de.unidu.is.gnuplot
Class Gnuplot

java.lang.Object
  extended byde.unidu.is.gnuplot.Gnuplot

public class Gnuplot
extends java.lang.Object

A class for creating evaluation plots with gnuplot, a common Unix/Linux plotting tool with a textual interface. Thus, this class might work only on Unix/Linux; anyway, it is not tested under Windows.

This class allows for

A mind.evaluation.gnuplot.Source describes a single plot curve which might be a function, a discrete (empirical) distribution or anything else.

The path to gnuplot is taken from the property gnuplot.bin.

Since:
2002-04-09
Version:
$Revision: 1.10 $, $Date: 2005/03/14 17:33:15 $
Author:
Henrik Nottelmann

Field Summary
protected  boolean bw
          Flag indicating if this is a b/w plot.
protected  boolean fig
          Flag indicating if this is a xfig plot.
protected  double maxx
          The maximum value for the x-axis (default is 0).
protected  double maxy
          The maximum value for the y-axis (default is 0).
protected  double minx
          The minimum value for the x-axis (default is 0).
protected  double miny
          The minimum value for the y-axis (default is 0).
protected  java.lang.String outputfile
          The name (absolute or relative) of the output EPS file, without extension .eps.
protected  java.util.List sources
          The registered sources.
protected  java.lang.String title
          The title of the plot.
protected  java.lang.String xlabel
          The label for the x-axis of the plot.
protected  java.lang.String ylabel
          The label for the y-axis of the plot.
 
Constructor Summary
Gnuplot()
           
 
Method Summary
 java.lang.StringBuffer addLaTeX(java.lang.StringBuffer latex)
          Adds LaTeX commands for including the result plot.
 void addSource(Source source)
          Adds a source to the plot.
 java.lang.String getGnuplotString()
          Returns the gnuplot commands.
 java.lang.String getLaTeX()
          Returns LaTeX commands for including the result plot.
 void run()
          Runs gnuplot and creates an .pdf file.
 void setBW()
          Sets the b/w mode.
 void setColor()
          Sets the color mode.
 void setFIG()
          Sets the fig output mode.
 void setLabels(java.lang.String xlabel, java.lang.String ylabel)
          Sets the labels for the x-axis and the y-axis of the plot.
 void setMinMaxX(double minx, double maxx)
          Sets the minimum and the maximum values for the x-axis.
 void setMinMaxY(double miny, double maxy)
          Sets the minimum and the maximum values for the y-axis.
 void setOutputfile(java.io.File outputfile)
          Sets the name (absolute or relative) of the output EPS file, without extension .eps.
 void setOutputfile(java.lang.String outputfile)
          Sets the name (absolute or relative) of the output EPS file, without extension .eps.
 void setPDF()
          Sets the pdf output mode.
 void setTitle(java.lang.String title)
          Sets the title of the plot.
 void write(java.lang.String file)
          Writes the gnuplot commands into a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputfile

protected java.lang.String outputfile
The name (absolute or relative) of the output EPS file, without extension .eps.


title

protected java.lang.String title
The title of the plot. If this variable is null (default), no title is used.


xlabel

protected java.lang.String xlabel
The label for the x-axis of the plot. If this variable is null (default), no label is used.


ylabel

protected java.lang.String ylabel
The label for the y-axis of the plot. If this variable is null (default), no label is used.


maxx

protected double maxx
The maximum value for the x-axis (default is 0).


maxy

protected double maxy
The maximum value for the y-axis (default is 0).


minx

protected double minx
The minimum value for the x-axis (default is 0).


miny

protected double miny
The minimum value for the y-axis (default is 0).


sources

protected java.util.List sources
The registered sources. Each source describes one plot curve.


bw

protected boolean bw
Flag indicating if this is a b/w plot. Default is color.


fig

protected boolean fig
Flag indicating if this is a xfig plot. Default is pdf.

Constructor Detail

Gnuplot

public Gnuplot()
Method Detail

setOutputfile

public void setOutputfile(java.lang.String outputfile)
Sets the name (absolute or relative) of the output EPS file, without extension .eps.

Parameters:
outputfile - name of the output file

setOutputfile

public void setOutputfile(java.io.File outputfile)
Sets the name (absolute or relative) of the output EPS file, without extension .eps.

Parameters:
outputfile - name of the output file

setBW

public void setBW()
Sets the b/w mode.


setColor

public void setColor()
Sets the color mode.


setFIG

public void setFIG()
Sets the fig output mode.


setPDF

public void setPDF()
Sets the pdf output mode.


setTitle

public void setTitle(java.lang.String title)
Sets the title of the plot. For no title, call setTitle(null). By default, no title is used.

Parameters:
title - title of the plot, or null

setLabels

public void setLabels(java.lang.String xlabel,
                      java.lang.String ylabel)
Sets the labels for the x-axis and the y-axis of the plot. For no labels, call setLabels(null,null). By default, no labels used.

Parameters:
xlabel - label for the x-axis, or null
ylabel - label for the y-axis, or null

setMinMaxX

public void setMinMaxX(double minx,
                       double maxx)
Sets the minimum and the maximum values for the x-axis. These values are only used if the are different. By default, both values are 0. labels used.

Parameters:
minx - minimum value for the x-axis
maxx - maximum value for the x-axis

setMinMaxY

public void setMinMaxY(double miny,
                       double maxy)
Sets the minimum and the maximum values for the y-axis. These values are only used if the are different. By default, both values are 0. labels used.

Parameters:
miny - minimum value for the y-axis
maxy - maximum value for the y-axis

addSource

public void addSource(Source source)
Adds a source to the plot. A source describes one plot curve.

If the minimum and the maximum values for the x-axis of the given source differ, they are taken into account for the minimum and the maximum values for the x-axis of this plot.

Parameters:
source - plot curve source to be added

write

public void write(java.lang.String file)
Writes the gnuplot commands into a file.

Parameters:
file - name of the file in which the plot commands are written into

getGnuplotString

public java.lang.String getGnuplotString()
Returns the gnuplot commands.

Returns:
gnuplot string, based on the settings of this instance

run

public void run()
Runs gnuplot and creates an .pdf file. The call waits until the plot is created. Errors from gnuplot are not handled in any way.


getLaTeX

public java.lang.String getLaTeX()
Returns LaTeX commands for including the result plot.

Returns:
LaTeX commands for including the result plot

addLaTeX

public java.lang.StringBuffer addLaTeX(java.lang.StringBuffer latex)
Adds LaTeX commands for including the result plot.

Parameters:
latex - string buffer for LaTeX commands