SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.charts.XYChart Class Referenceabstract

This class provides tools to create charts from data in a simple way. More...

Inheritance diagram for umontreal.ssj.charts.XYChart:
umontreal.ssj.charts.EmpiricalChart umontreal.ssj.charts.HistogramChart umontreal.ssj.charts.ScatterChart umontreal.ssj.charts.XYLineChart umontreal.ssj.charts.PPPlot umontreal.ssj.charts.QQPlot umontreal.ssj.charts.YListChart

Public Member Functions

JFreeChart getJFreeChart ()
 Returns the JFreeChart object associated with this chart.
Axis getXAxis ()
 Returns the chart’s domain axis ( \(x\)-axis) object.
Axis getYAxis ()
 Returns the chart’s range axis ( \(y\)-axis) object.
abstract JFrame view (int width, int height)
 Displays chart on the screen using Swing.
String getTitle ()
 Gets the current chart title.
void setTitle (String title)
 Sets a title to this chart.
void setprobFlag (boolean flag)
 Must be set true when plotting probabilities, false otherwise.
void setAutoRange ()
 The \(x\) and the \(y\) ranges of the chart are set automatically.
void setAutoRange (boolean right, boolean top)
 The \(x\) and the \(y\) ranges of the chart are set automatically.
void setAutoRange00 (boolean xZero, boolean yZero)
 The \(x\) and the \(y\) ranges of the chart are set automatically.
void setManualRange (double[] range)
 Sets the \(x\) and \(y\) ranges of the chart using the format: range = [xmin, xmax, ymin, ymax].
void setManualRange (double[] range, boolean right, boolean top)
 Sets the \(x\) and \(y\) ranges of the chart using the format: range = [xmin, xmax, ymin, ymax].
void setManualRange00 (double[] range, boolean xZero, boolean yZero)
 Sets the \(x\) and \(y\) ranges of the chart using the format: range = [xmin, xmax, ymin, ymax].
double getChartMargin ()
 Returns the chart margin, which is the fraction by which the chart is enlarged on its borders.
void setChartMargin (double margin)
 Sets the chart margin to margin.
abstract void setTicksSynchro (int s)
 Synchronizes \(x\)-axis ticks to the \(s\)-th series.
void drawVerticalLine (double x, String name, double yfrac, boolean right)
 Draws a vertical line on the chart at \(x\)-coordinate x.

Latex-specific methods @{

void enableGrid (double xstep, double ystep)
 Puts a grid on the background.
void disableGrid ()
 Disables the background grid.
abstract String toLatex (double width, double height)
 Exports the chart to a LaTeX source code using PGF/TikZ.
void toLatexFile (String fileName, double width, double height)
 Transforms the chart to LaTeX form and writes it in file fileName.
void setLatexDocFlag (boolean flag)
 Flag to remove the \documentclass (and other) commands in the created LaTeX files.

Detailed Description

This class provides tools to create charts from data in a simple way.

Its main feature is to produce TikZ/PGF (see WWW link http://sourceforge.net/projects/pgf/) compatible source code which can be included in LaTeX documents, but it can also produce charts in other formats. One can easily create a new chart, and customize its appearance using methods of this class, with the encapsulated umontreal.ssj.charts.SSJXYSeriesCollection object representing the data, and the two umontreal.ssj.charts.Axis objects representing the axes. All these classes depend on the JFreeChart API (see WWW link http://www.jfree.org/jfreechart/) which provides tools to build charts with Java, to draw them, and export them to files. However, only basic features are used here.

Moreover, XYChart provides methods to plot data using a MATLAB friendly syntax. None of these methods provides new features; they just propose a different syntax to create charts. Therefore some features are unavailable when using these methods only.

Definition at line 56 of file XYChart.java.

Member Function Documentation

◆ disableGrid()

void umontreal.ssj.charts.XYChart.disableGrid ( )

Disables the background grid.

Definition at line 399 of file XYChart.java.

◆ drawVerticalLine()

void umontreal.ssj.charts.XYChart.drawVerticalLine ( double x,
String name,
double yfrac,
boolean right )

Draws a vertical line on the chart at \(x\)-coordinate x.

name is written near the line at \(y\) position yfrac (a fraction of the \(y\)-size of the chart, 0 is the bottom, 1 is the top); if right is true, name is written on the right of the line, else on the left.

Parameters
x\(x\)-coordinate of the line
namedescription of the line
yfrac\(y\)-position of name
right\(x\)-position of name

Definition at line 359 of file XYChart.java.

◆ enableGrid()

void umontreal.ssj.charts.XYChart.enableGrid ( double xstep,
double ystep )

Puts a grid on the background.

It is important to note that the grid is always shifted in such a way that it contains the axes. Thus, the grid does not always have an intersection at the corner points; this occurs only if the corner points are multiples of the steps: xstep and ystep sets the step in each direction.

Parameters
xstepsets the step in the x-direction.
ystepsets the step in the y-direction.

Definition at line 390 of file XYChart.java.

◆ getChartMargin()

double umontreal.ssj.charts.XYChart.getChartMargin ( )

Returns the chart margin, which is the fraction by which the chart is enlarged on its borders.

The default value is \(0.02\).

Definition at line 325 of file XYChart.java.

◆ getJFreeChart()

JFreeChart umontreal.ssj.charts.XYChart.getJFreeChart ( )

Returns the JFreeChart object associated with this chart.

Returns
the associated JFreeChart object.

Definition at line 82 of file XYChart.java.

◆ getTitle()

String umontreal.ssj.charts.XYChart.getTitle ( )

Gets the current chart title.

Returns
Chart title.

Definition at line 114 of file XYChart.java.

◆ getXAxis()

Axis umontreal.ssj.charts.XYChart.getXAxis ( )

Returns the chart’s domain axis ( \(x\)-axis) object.

Returns
chart’s domain axis ( \(x\)-axis) object.

Definition at line 91 of file XYChart.java.

◆ getYAxis()

Axis umontreal.ssj.charts.XYChart.getYAxis ( )

Returns the chart’s range axis ( \(y\)-axis) object.

Returns
chart’s range axis ( \(y\)-axis) object.

Definition at line 100 of file XYChart.java.

◆ setAutoRange() [1/2]

void umontreal.ssj.charts.XYChart.setAutoRange ( )

The \(x\) and the \(y\) ranges of the chart are set automatically.

Definition at line 140 of file XYChart.java.

◆ setAutoRange() [2/2]

void umontreal.ssj.charts.XYChart.setAutoRange ( boolean right,
boolean top )

The \(x\) and the \(y\) ranges of the chart are set automatically.

If right is true, the vertical axis will be on the left of the points, otherwise on the right. If top is true, the horizontal axis will be under the points, otherwise above the points.

Parameters
righttrue if the x-values on the right of axis.
toptrue if the y-values on the top of axis.

Reimplemented in umontreal.ssj.charts.HistogramChart.

Definition at line 153 of file XYChart.java.

◆ setAutoRange00()

void umontreal.ssj.charts.XYChart.setAutoRange00 ( boolean xZero,
boolean yZero )

The \(x\) and the \(y\) ranges of the chart are set automatically.

If xZero is true, the vertical axis will pass through the point \((0, y)\). If yZero is true, the horizontal axis will pass through the point \((x, 0)\).

Parameters
xZerotrue if vertical axis passes through point 0
yZerotrue if horizontal axis passes through point 0

Definition at line 251 of file XYChart.java.

◆ setChartMargin()

void umontreal.ssj.charts.XYChart.setChartMargin ( double margin)

Sets the chart margin to margin.

It is the fraction by which the chart is enlarged on its borders. Restriction: \(\mathtt{margin} \ge0\).

Parameters
marginmargin percentage amount.

Definition at line 335 of file XYChart.java.

◆ setLatexDocFlag()

void umontreal.ssj.charts.XYChart.setLatexDocFlag ( boolean flag)

Flag to remove the \documentclass (and other) commands in the created LaTeX files.

If flag is true, then when charts are translated into LaTeX form, it will be as a self-contained file that can be directly compiled with LaTeX. However, in this form, the file cannot be included in another LaTeX file without causing compilation errors because of the multiple instructions \documentclass and \begin{document}. By setting flag to false, these instructions will be removed from the LaTeX chart files, which can then be included in a master LaTeX file. By default, the flag is true.

Definition at line 450 of file XYChart.java.

◆ setManualRange() [1/2]

void umontreal.ssj.charts.XYChart.setManualRange ( double[] range)

Sets the \(x\) and \(y\) ranges of the chart using the format: range = [xmin, xmax, ymin, ymax].

Parameters
rangenew axis ranges.

Definition at line 261 of file XYChart.java.

◆ setManualRange() [2/2]

void umontreal.ssj.charts.XYChart.setManualRange ( double[] range,
boolean right,
boolean top )

Sets the \(x\) and \(y\) ranges of the chart using the format: range = [xmin, xmax, ymin, ymax].

If right is true, the vertical axis will be on the left of the points, otherwise on the right. If top is true, the horizontal axis will be under the points, otherwise above the points.

Parameters
rangenew axis ranges.
righttrue if the x-values on the right.
toptrue if the y-values on the top.

Definition at line 275 of file XYChart.java.

◆ setManualRange00()

void umontreal.ssj.charts.XYChart.setManualRange00 ( double[] range,
boolean xZero,
boolean yZero )

Sets the \(x\) and \(y\) ranges of the chart using the format: range = [xmin, xmax, ymin, ymax].

If xZero is true, the vertical axis will pass through the point \((0, y)\). If yZero is true, the horizontal axis will pass through the point \((x, 0)\).

Parameters
rangenew axis ranges.
xZerotrue if vertical axis passes through point 0
yZerotrue if horizontal axis passes through point 0

Definition at line 317 of file XYChart.java.

◆ setprobFlag()

void umontreal.ssj.charts.XYChart.setprobFlag ( boolean flag)

Must be set true when plotting probabilities, false otherwise.

Parameters
flagtrue for plotting probabilities

Definition at line 133 of file XYChart.java.

◆ setTicksSynchro()

abstract void umontreal.ssj.charts.XYChart.setTicksSynchro ( int s)
abstract

Synchronizes \(x\)-axis ticks to the \(s\)-th series.

\(x\)-values.

Parameters
sseries.

Reimplemented in umontreal.ssj.charts.EmpiricalChart, umontreal.ssj.charts.HistogramChart, umontreal.ssj.charts.ScatterChart, and umontreal.ssj.charts.XYLineChart.

◆ setTitle()

void umontreal.ssj.charts.XYChart.setTitle ( String title)

Sets a title to this chart.

This title will appear on the chart displayed by method view.

Parameters
titlechart title.

Definition at line 124 of file XYChart.java.

◆ toLatex()

abstract String umontreal.ssj.charts.XYChart.toLatex ( double width,
double height )
abstract

Exports the chart to a LaTeX source code using PGF/TikZ.

This method constructs and returns a string that can be written to a LaTeX document to render the plot. width and height represents the width and the height of the produced chart. These dimensions do not take into account the axes and labels extra space. The width and the height of the chart are measured in centimeters.

Parameters
widthChart’s width in centimeters.
heightChart’s height in centimeters.
Returns
LaTeX source code.

Reimplemented in umontreal.ssj.charts.EmpiricalChart, umontreal.ssj.charts.HistogramChart, umontreal.ssj.charts.ScatterChart, and umontreal.ssj.charts.XYLineChart.

◆ toLatexFile()

void umontreal.ssj.charts.XYChart.toLatexFile ( String fileName,
double width,
double height )

Transforms the chart to LaTeX form and writes it in file fileName.

The chart’s width and height (in centimeters) are width and height.

Definition at line 421 of file XYChart.java.

◆ view()

abstract JFrame umontreal.ssj.charts.XYChart.view ( int width,
int height )
abstract

The documentation for this class was generated from the following file: