SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Protected Member Functions | List of all members
ScatterChart Class Reference

This class provides tools to create and manage scatter plots. More...

Inheritance diagram for ScatterChart:
[legend]
Collaboration diagram for ScatterChart:
[legend]

Public Member Functions

 ScatterChart ()
 Initializes a new ScatterChart instance with an empty data set.
 
 ScatterChart (String title, String XLabel, String YLabel, double[][]... data)
 Initializes a new ScatterChart instance with data data. More...
 
 ScatterChart (String title, String XLabel, String YLabel, double[][] data, int numPoints)
 Initializes a new ScatterChart instance with sets of points data. More...
 
 ScatterChart (String title, String XLabel, String YLabel, double[][] data, int x, int y)
 Initializes a new ScatterChart instance using subsets of data. More...
 
 ScatterChart (String title, String XLabel, String YLabel, DoubleArrayList... data)
 Initializes a new ScatterChart instance with data data. More...
 
 ScatterChart (String title, String XLabel, String YLabel, XYSeriesCollection data)
 Initializes a new ScatterChart instance with data data. More...
 
int add (double[] x, double[] y, String name, String plotStyle)
 Adds a data series into the series collection. More...
 
int add (double[] x, double[] y)
 Adds a data series into the series collection. More...
 
int add (double[] x, double[] y, int numPoints)
 Adds a data series into the series collection. More...
 
XYListSeriesCollection getSeriesCollection ()
 Returns the chart’s dataset. More...
 
void setSeriesCollection (XYListSeriesCollection dataset)
 Links a new dataset to the current chart. More...
 
void setTicksSynchro (int s)
 Synchronizes \(X\)-axis ticks to the \(s\)-th series \(x\)-values. More...
 
JFrame view (int width, int height)
 Displays chart on the screen using Swing. More...
 
LaTex-specific method
String toLatex (double width, double height)
 
- Public Member Functions inherited from XYChart
JFreeChart getJFreeChart ()
 Returns the JFreeChart object associated with this chart. More...
 
Axis getXAxis ()
 Returns the chart’s domain axis ( \(x\)-axis) object. More...
 
Axis getYAxis ()
 Returns the chart’s range axis ( \(y\)-axis) object. More...
 
abstract JFrame view (int width, int height)
 Displays chart on the screen using Swing.
 
String getTitle ()
 Gets the current chart title. More...
 
void setTitle (String title)
 Sets a title to this chart. More...
 
void setprobFlag (boolean flag)
 Must be set true when plotting probabilities, false otherwise. More...
 
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. More...
 
void setAutoRange00 (boolean xZero, boolean yZero)
 The \(x\) and the \(y\) ranges of the chart are set automatically. More...
 
void setManualRange (double[] range)
 Sets the \(x\) and \(y\) ranges of the chart using the format: range = [xmin, xmax, ymin, ymax]. More...
 
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]. More...
 
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]. More...
 
double getChartMargin ()
 Returns the chart margin, which is the fraction by which the chart is enlarged on its borders. More...
 
void setChartMargin (double margin)
 Sets the chart margin to margin. More...
 
abstract void setTicksSynchro (int s)
 Synchronizes \(x\)-axis ticks to the \(s\)-th series \(x\)-values. More...
 
void drawVerticalLine (double x, String name, double yfrac, boolean right)
 Draws a vertical line on the chart at \(x\)-coordinate x. More...
 
void enableGrid (double xstep, double ystep)
 Puts a grid on the background. More...
 
void disableGrid ()
 Disables the background grid.
 
abstract String toLatex (double width, double height)
 Exports the chart to a LaTeX source code using PGF/TikZ. More...
 
void toLatexFile (String fileName, double width, double height)
 Transforms the chart to LaTeX form and writes it in file fileName. More...
 
void setLatexDocFlag (boolean flag)
 Flag to remove the \documentclass (and other) commands in the created LaTeX files. More...
 

Protected Member Functions

void init (String title, String XLabel, String YLabel)
 
void initAxis ()
 
- Protected Member Functions inherited from XYChart
void setAutoRange (boolean xZero, boolean yZero, boolean right, boolean top)
 
void setTick0Flags ()
 
double computeXScale (double position)
 
double computeYScale (double position)
 
double computeScale (double[] bounds)
 

Additional Inherited Members

- Protected Attributes inherited from XYChart
Axis XAxis
 
Axis YAxis
 
SSJXYSeriesCollection dataset
 
JFreeChart chart
 
boolean latexDocFlag = true
 
boolean autoRange
 
double [] manualRange
 
boolean grid = false
 
double xstepGrid
 
double ystepGrid
 
boolean probFlag = false
 
double chartMargin = 0.02
 

Detailed Description

This class provides tools to create and manage scatter plots.

Using the ScatterChart class is the simplest way to produce scatter plots only. Each ScatterChart object is linked with a umontreal.ssj.charts.XYListSeriesCollection data set.

Constructor & Destructor Documentation

◆ ScatterChart() [1/5]

ScatterChart ( String  title,
String  XLabel,
String  YLabel,
double...  data[][] 
)

Initializes a new ScatterChart instance with data data.

title is a title, XLabel is a short description of the \(x\)-axis and YLabel a short description of the \(y\)-axis. The input parameter data represents sets of plotting data. For example, if one \(n\)-row matrix data1 is given as argument data, then the first row data1 \([0]\) represents the \(x\)-coordinate vector, and every other row data1 \([i], i=1,…, n-1\), represents the \(y\)-coordinates of a set of points. Therefore matrix data1 corresponds to \(n-1\) sets of points, all with the same \(x\)-coordinates. However, one may want to plot sets of points with different \(x\)-coordinates. In that case, one should give the points as matrices with two rows. For examples, if the argument data is made of three 2-row matrices data1, data2 and data3, then they represents three different sets of points, data* \([0]\) giving the \(x\)-coordinates, and data* \([1]\) the \(y\)-coordinates of the points.

Parameters
titlechart title.
XLabelLabel on \(x\)-axis.
YLabelLabel on \(y\)-axis.
dataseries of point sets.

◆ ScatterChart() [2/5]

ScatterChart ( String  title,
String  XLabel,
String  YLabel,
double  data[][],
int  numPoints 
)

Initializes a new ScatterChart instance with sets of points data.

title is a title, XLabel is a short description of the \(x\)-axis, and YLabel a short description of the \(y\)-axis. If data is a \(n\)-row matrix, then the first row data \([0]\) represents the \(x\)-coordinate vector, and every other row data \([i], i=1,…, n-1\), represents a \(y\)-coordinate vector. Therefore matrix data \([i][ ]\), \(i=0,…, n-1\), corresponds to \(n-1\) sets of points, all with the same \(x\)-coordinates. However, only the first numPoints of each set data \([i]\) (i.e. the first numPoints columns of each row) will be plotted.

Parameters
titlechart title.
XLabelLabel on \(x\)-axis.
YLabelLabel on \(y\)-axis.
dataseries of point sets.
numPointsNumber of points to plot

◆ ScatterChart() [3/5]

ScatterChart ( String  title,
String  XLabel,
String  YLabel,
double  data[][],
int  x,
int  y 
)

Initializes a new ScatterChart instance using subsets of data.

data[x][.] will form the \(x\)-coordinates and data[y][.] will form the \(y\)-coordinates of the chart. title sets a title, XLabel is a short description of the \(x\)-axis, and YLabel is a short description of the \(y\)-axis. Warning: if the new \(x\)-axis coordinates are not monotone increasing, then they will automatically be sorted in increasing order so the points will be reordered, but the original data is not changed.

Parameters
titlechart title.
XLabelLabel on \(x\)-axis.
YLabelLabel on \(y\)-axis.
dataseries of point sets.
xIndex of data forming the \(x\)-coordinates
yIndex of data forming the \(y\)-coordinates

◆ ScatterChart() [4/5]

ScatterChart ( String  title,
String  XLabel,
String  YLabel,
DoubleArrayList...  data 
)

Initializes a new ScatterChart instance with data data.

The input parameter data represents a set of plotting data. A DoubleArrayList from the Colt library is used to store the data. The description is similar to the above constructor with double[]... data.

Parameters
titlechart title.
XLabelLabel on \(x\)-axis.
YLabelLabel on \(y\)-axis.
dataseries of point sets.

◆ ScatterChart() [5/5]

ScatterChart ( String  title,
String  XLabel,
String  YLabel,
XYSeriesCollection  data 
)

Initializes a new ScatterChart instance with data data.

The input parameter data represents a set of plotting data. org.jfree.data.xy.XYSeriesCollection is a JFreeChart container class to store \(XY\) plots.

Parameters
titlechart title.
XLabelLabel on \(x\)-axis.
YLabelLabel on \(y\)-axis.
dataseries collection.

Member Function Documentation

◆ add() [1/3]

int add ( double []  x,
double []  y,
String  name,
String  plotStyle 
)

Adds a data series into the series collection.

Vector x represents the \(x\)-coordinates and vector y represents the \(y\)-coordinates of the series. name and plotStyle are the name and the plot style associated to the series.

Parameters
x\(x_i\) coordinates.
y\(y_i\) coordinates.
nameName of the series.
plotStylePlot style of the series.
Returns
Integer that represent the new point set’s position in the JFreeChart XYSeriesCollection object.

◆ add() [2/3]

int add ( double []  x,
double []  y 
)

Adds a data series into the series collection.

Vector x represents the \(x\)-coordinates and vector y represents the \(y\)-coordinates of the series.

Parameters
x\(x_i\) coordinates.
y\(y_i\) coordinates.
Returns
Integer that represent the new point set’s position in the JFreeChart XYSeriesCollection object.

◆ add() [3/3]

int add ( double []  x,
double []  y,
int  numPoints 
)

Adds a data series into the series collection.

Vector x represents the \(x\)-coordinates and vector y represents the \(y\)-coordinates of the series. Only the first numPoints of x and y will be taken into account for the new series.

Parameters
x\(x_i\) coordinates.
y\(y_i\) coordinates.
numPointsNumber of points to add.
Returns
Integer that represent the new point set’s position in the JFreeChart XYSeriesCollection object.

◆ getSeriesCollection()

XYListSeriesCollection getSeriesCollection ( )

Returns the chart’s dataset.

Returns
the chart’s dataset.

◆ setSeriesCollection()

void setSeriesCollection ( XYListSeriesCollection  dataset)

Links a new dataset to the current chart.

Parameters
datasetnew dataset.

◆ setTicksSynchro()

void setTicksSynchro ( int  s)

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

Parameters
sseries used to define ticks.

◆ view()

JFrame view ( int  width,
int  height 
)

Displays chart on the screen using Swing.

This method creates an application containing a chart panel displaying the chart. The created frame is positioned on-screen, and displayed before it is returned. The width and the height of the chart are measured in pixels.

Parameters
widthframe width in pixels.
heightframe height in pixels.
Returns
frame containing the chart.

;


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