SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
Package umontreal.ssj.charts

Charts generation. More...

Classes

class  Axis
 Represents an axis of a chart encapsulated by an instance of XYChart. More...
class  BoxChart
 Provides tools to create and manage box-and-whisker plots. More...
class  BoxSeriesCollection
 This class stores data used in a umontreal.ssj.charts.CategoryChart. More...
class  CategoryChart
 This class provides tools to create charts from data in a simple way. More...
class  ContinuousDistChart
 This class provides tools to plot the density and the cumulative probability of a continuous probability distribution. More...
class  CustomHistogramDataset
 A dataset that can be used for creating histograms. More...
class  DiscreteDistIntChart
 This class provides tools to plot the mass function and the cumulative probability of a discrete probability distribution over the integers. More...
class  EmpiricalChart
 Provides tools to create and manage empirical plots, which are used to plot empirical distributions. More...
class  EmpiricalRenderer
 A renderer that draws horizontal lines between points and/or draws shapes at each data point to provide an empirical style chart. More...
class  EmpiricalSeriesCollection
 Stores data used in a EmpiricalChart. More...
class  HistogramChart
 Provides tools to create and manage histograms. More...
class  HistogramSeriesCollection
 Stores data used in a HistogramChart. More...
class  MultipleDatasetChart
 Provides tools to plot many datasets on the same chart. More...
class  PlotFormat
 Provide tools to import and export data set tables to and from Gnuplot, MATLAB and Mathematica compatible formats, or customized format. More...
class  PPPlot
 Provides PP-plot (probability-probability plot) objects that compare two probability distributions. More...
class  QQPlot
 This class implements QQ-plot (or quantile-quantile plot) objects that compare two probability distributions. More...
class  ScatterChart
 Provides tools to create and manage scatter plots. More...
class  SSJCategorySeriesCollection
 Stores data used in a CategoryChart. More...
class  SSJXYSeriesCollection
 Stores data used in a XYChart. More...
class  XYChart
 This class provides tools to create charts from data in a simple way. More...
class  XYLineChart
 Provides tools to create and manage curve plots. More...
class  YListChart
 Extends XYLineChart; each YListChart object is associated with a YListSeriesCollection data set. More...
class  YListSeriesCollection
 This class extends umontreal.ssj.charts.XYListSeriesCollection. More...

Functions

 XYListSeriesCollection ()
 Stores data used in a XYLineChart or in other related charts, and provides complementary tools to draw simple curves.
 XYListSeriesCollection (double[][]... data)
 Creates a new XYListSeriesCollection instance with default parameters and given data series.
 XYListSeriesCollection (double[][] data, int numPoints)
 Creates a new XYListSeriesCollection instance with default parameters and given points data.
 XYListSeriesCollection (DoubleArrayList... data)
 Creates a new XYListSeriesCollection instance with default parameters and given data.
 XYListSeriesCollection (XYSeriesCollection data)
 Creates a new XYListSeriesCollection instance with default parameters and given data series.
Data control methods @{
int add (double[] x, double[] y)
 Adds a data series into the series collection.
int add (double[] x, double[] y, int numPoints)
 Adds a data series into the series collection.
int add (double[][] data)
 Adds a data series into the series collection.
int add (double[][] data, int numPoints)
 Adds data series into the series collection.
int add (DoubleArrayList data)
 Adds a data series into the series collection.
String getName (int series)
 Gets the current name of the selected series.
void setName (int series, String name)
 Sets the name of the selected series.
Rendering methods @{
void enableAutoCompletion ()
 Enables the auto completion option.
void disableAutoCompletion ()
 Disables auto completion option.
String getMarksType (int series)
 Returns the mark type associated with the seriesth data series.
void setMarksType (int series, String marksType)
 Adds marks on the points of a data series.
String getDashPattern (int series)
 Returns the dash pattern associated with the seriesth data series.
void setDashPattern (int series, String dashPattern)
 Selects dash pattern for a data series.
String getPlotStyle (int series)
 Gets the current plot style for the selected series.
void setPlotStyle (int series, String plotStyle)
 Selects the plot style for a given series.

Detailed Description

Charts generation.

This package contains utility classes to produce charts either for LaTeX or to be displayed on the computer screen, directly from a Java program. It was written mostly by students before 2010 and it is not perfect. For LaTeX, the package generates TikZ source code, which can be adjusted manually afterwards if needed.

The package is built over the open source JFreeChart software http://www.jfree.org/jfreechart/, which is distributed under the terms of the GNU Lesser General Public License (LGPL). It provides tools for the construction, visualization, and customization of XY plots, histograms, and empirical styled charts. It offers facilities to export charts to PGF/TikZ source code, which can be included into LaTeX documents http://sourceforge.net/projects/pgf. The user does not need to be familiar with the JFreeChart package or the TikZ syntax to use these tools, except if customization is required. For this, one may see the API specification of JFreeChart, and the reference manual of TikZ.

The two basic abstract classes of package charts are XYChart and CategoryChart. All other charts inherit from one of these two. Charts are managed by the mother class which contains the data tables in a SeriesCollection object, and the information about \(x\)-axis and \(y\)-axis in Axis instances. All these objects encapsulate JFreeChart instances along with some additional TikZ-specific attributes. The method XYChart.view displays charts on screen while the method toLatex formats and returns a String which contains the TikZ source code that can be written to a LaTeX file.

Several chart styles are available and each one is represented by a subclass of XYChart or of CategoryChart. The XYLineChart uses XYListSeriesCollection to plot curves and lines, the HistogramSeriesCollection class is used by HistogramChart to plot histograms, and the EmpiricalSeriesCollection is used by EmpiricalChart to plot empirical style charts. It is possible to draw a scatter plot or a box plot using ScatterChart or BoxChart respectively. These concrete subclasses have similar APIs, but they are specialized for different kinds of charts.

These charts can be customized using *SeriesCollection subclasses and Axis. First, one can use methods in the XYChart class for setting the range values and a background grid. One can also use the method getSeriesCollection() for subclasses of charts to obtain the dataset of the chart, which is represented by a *SeriesCollection object. This dataset can be customized in the following ways by calling methods on the series collection: selecting color, changing plot style (straight lines, curves, marks only, etc.), putting marks on points, setting a label and selecting the dash pattern (solid, dotted, dashed, …). The available properties depend on the type of chart. Moreover, objects representing the axes can be retrieved with XYChart.getXAxis for the \(x\)-axis, and XYChart.getYAxis for the \(y\)-axis. By using methods in Axis, many customizations are possible: setting a label to the axis, setting ticks labels and values (auto ticks, periodical ticks or manually defined ticks) and changing the twin axis position on the current axis to select where axes must appear. These settings are independent for each axis.

Each chart object from SSJ encapsulates a JFreeChart object: a XYChart instance contains a JFreeChart instance from JFreeChart API, a *SeriesCollection contains a XYDataset and a XYItemRenderer, and finally an Axis contains a NumberAxis. So any parameter proposed by JFreeChart is reachable through getter methods. However, changing the JFreeChart parameters directly may have no impact on the produced TikZ source code.

The two special classes ContinuousDistChart and DiscreteDistIntChart can be used to plot probability densities, mass functions, and cumulative probabilities for continuous or discrete distributions, which are implemented in package umontreal.ssj.probdist of SSJ.

The package charts provides additional tools for formatting data plot, and creating charts with multiple datasets. The PlotFormat class offers basic tools to import and export data from files. Supported file formats are GNUPlot and standard CSV, which is widely used and accepted by most mathematical softwares such as MATLAB and Mathematica. Customizing file input and output format is also possible. Finally MultipleDatasetChart provides tools to plot with different styles on the same chart.

Examples

For a series of examples, see the pdf documentation.

The following examples demonstrate how to build charts with this package.

A simple example of chart creation  [normalchart]

package charts;
import umontreal.ssj.charts.XYLineChart;
public class NormalChart {
private static double[][] getPoints() {
// The density of the standard normal probability distribution
// points contains one array for X values and one array for Y values
final int N = 400;
double[][] points = new double[2][N + 1];
final double CPI = Math.sqrt(2 * Math.PI);
for (int i = 0; i <= N; ++i) {
double x = -3.5 + i * 7.0 / N;
points[0][i] = x;
points[1][i] = Math.exp(-x * x / 2.0) / CPI;
}
return points;
}
public static void main(String[] args) {
double[][] points = getPoints();
XYLineChart chart = new XYLineChart(null, "X", null, points);
chart.setAutoRange00(true, true); // Axes pass through (0,0)
chart.toLatexFile("NormalChart.tex", 12, 8);
chart.view(800, 500);
}
}
The density of the standard normal.

The first program, displayed in Listing  normalchart, shows the simplest way to export charts from data tables. First, a curve is defined with regularly spaced \(x\)-coordinates in method getPoints; it represents the curve \(y = e^{-x^2/2}/\sqrt{2\pi}\), the density of the standard normal probability distribution. Arrays points[0] contain the \(x\)-coordinates and points[1] the \(y\)-coordinates of the points. Figure  normalchart-res presents the resulting chart if the produced TikZ code is added to a LaTeX document using the tikz package, and compiled using LaTeX or PdfLaTeX.

A simpler way to plot a probability density or a distribution function is to use the class umontreal.ssj.charts.ContinuousDistChart, as shown in Listing  normaldist where however, the normal density will be plotted directly on the screen.

The normal density  [normaldist]

package charts;
import umontreal.ssj.probdist.*;
import umontreal.ssj.charts.*;
public class ContDistPlot {
public static void main(String[] args) {
ContinuousDistribution dist = new NormalDist();
ContinuousDistChart plot = new ContinuousDistChart(dist, -3.5, 3.5, 1000);
plot.viewDensity(600, 400);
}
}
This class provides tools to plot the density and the cumulative probability of a continuous probabil...
Classes implementing continuous distributions should inherit from this base class.

The next example, displayed in Listing  poissonchart, plots the probability mass function for a Poisson distribution with \(\lambda= 50\) by simply creating an instance of umontreal.ssj.charts.DiscreteDistIntChart. Figure  poissonchart-res presents the resulting chart obtained from PdfLaTeX.

The probabilities of the Poisson distribution with \(\lambda= 50\).

Probabilities of the Poisson distribution  [poissonchart]

package charts;
import umontreal.ssj.probdist.*;
import umontreal.ssj.charts.*;
import java.io.*;
public class DistIntTest {
public static void main(String[] args) throws IOException {
PoissonDist dist = new PoissonDist(50);
// Export to Latex format
String output = dic.toLatexProb(12, 8); // 12cm width, 8cm height
Writer file = new FileWriter("DistIntTest.tex");
file.write(output);
file.close();
}
}
This class provides tools to plot the mass function and the cumulative probability of a discrete prob...
String toLatexProb(int width, int height)
Similar to toLatexCdf, but for the probability instead of the cdf.

The next program, displayed in Listing  simplechart, shows how to export several charts from data tables. First, three curves are defined with regularly spaced \(x\)-coordinates in methods getPoints*; they represent the curves \(y = \sqrt{x}\), \(y = \cos(x)\) and \(y = x+2\), respectively. Array points[0] contains the \(x\)-coordinates and points[1] the \(y\)-coordinates of the points. Figure  simplechart-res presents the resulting chart if the produced TikZ code is added to a LaTeX document using the tikz package, and compiled using LaTeX or PdfLaTeX.

Three curves on the same chart  [simplechart]

package charts;
import umontreal.ssj.charts.XYLineChart;
public class ChartTest1 {
private static double[][] getPoints1() {
double[][] points = new double[2][200];
for (int i = 0; i < points[0].length; i++) {
double x = i / 25.0;
points[0][i] = x;
points[1][i] = Math.sqrt(x);
}
return points;
}
private static double[][] getPoints2() {
double[][] points = new double[2][21];
for (int i = 0; i < points[0].length; i++) {
double x = -Math.PI + 2 * i * Math.PI / (points[0].length - 1);
points[0][i] = x;
points[1][i] = Math.cos(x);
}
return points;
}
private static double[][] getPoints3() {
double[][] points = new double[2][11];
for (int i = 0; i < points[0].length; i++) {
points[0][i] = -5 + i;
points[1][i] = -3 + i;
}
return points;
}
public static void main(String[] args) {
// Get data; data1 has length 2 and contains one array for
// X-axis values, and one array for Y-axis values.
double[][] data1 = getPoints1();
double[][] data2 = getPoints2();
double[][] data3 = getPoints3();
// Create a new chart with the previous data series.
XYLineChart chart = new XYLineChart(null, "X", "Y", data1, data2, data3);
chart.toLatexFile("ChartTest1.tex", 12, 8);
}
}
Results for three curves on the same chart.

The next example, given in Listing  customchart, shows how to customize a chart. First, three curves are defined as in example  simplechart above and the chart is created. Then the axes are customized by adding labels at chosen values on the \(x\)-axis. On the \(y\)-axis, successive labels are set regularly at points 1 unit apart. Then the data plot itself is customized. A new color is created in the RGB model for the first curve which also receives a label name and a dash plot style. Similarly, the other two curves receive their label name, plot style and color. Note that the third curve is drawn in the ORANGE color predefined in the AWT package of the standard Java toolkit. Finally, the charts are exported to a file in LaTeX format. If the file is compiled with LaTeX or PdfLaTeX, the resulting chart will appear as displayed in Figure  customchart-res.

Code for creating and customizing a chart  [customchart]

package charts;
import umontreal.ssj.charts.*;
import java.awt.Color;
public class ChartTest2 {
private static double[][] getPoints1() {
double[][] points = new double[2][40];
for (int i = 0; i < points[0].length; i++) {
double x = i / 4.0;
points[0][i] = x;
points[1][i] = Math.sqrt(x);
}
return points;
}
private static double[][] getPoints2() {
double[][] points = new double[2][21];
for (int i = 0; i < points[0].length; i++) {
double x = -Math.PI + 2 * i * Math.PI / (points[0].length - 1);
points[0][i] = x;
points[1][i] = Math.cos(x);
}
return points;
}
private static double[][] getPoints3() {
double[][] points = new double[2][11];
for (int i = 0; i < points[0].length; i++) {
points[0][i] = -5 + i;
points[1][i] = -3 + i;
}
return points;
}
public static void main(String[] args) {
double[][] data1 = getPoints1();
double[][] data2 = getPoints2();
double[][] data3 = getPoints3();
// Create a new chart with the previous data series.
XYLineChart chart = new XYLineChart(null, "X", "Y", data1, data2, data3);
// Customizing axes
Axis xaxis = chart.getXAxis();
Axis yaxis = chart.getYAxis();
String[] labels = { "-9", "$-\\lambda$", "$-\\sqrt{2}$", "0", "$\\frac{14}{\\pi}$", "\\LaTeX" };
double[] values = { -9, -5, -Math.sqrt(2), 0, 14.0 / Math.PI, 9 };
xaxis.setLabels(values, labels);
yaxis.setLabels(1);
// Data plots customizing
XYListSeriesCollection collec = chart.getSeriesCollection();
collec.setColor(0, new Color(0, 64, 128));
collec.setName(0, "$f(x) = \\sqrt(x)$");
collec.setMarksType(0, "");
collec.setDashPattern(0, "dotted");
collec.setName(1, "$f(x) = \\cos(x)$");
collec.setMarksType(1, "");
collec.setColor(2, Color.ORANGE);
collec.setPlotStyle(2, "ycomb,very thick");
collec.setMarksType(2, "*");
// Export to LaTex format
chart.toLatexFile("ChartTest2.tex", 12, 8); // 12cm width, 8cm height
}
}
XYListSeriesCollection()
Stores data used in a XYLineChart or in other related charts, and provides complementary tools to dra...
A customized chart.

The next example, given in Listing  empiricalchart, shows how to plot and customize empirical distributions. First, two empirical distributions are defined from a sample of points obtained from a uniform generator and a Beta \((3, 1)\) generator, both on the interval \([0, 1]\). Then an empirical chart is created to plot these two distributions. The first distribution is plotted in MAGENTA color with filled square marks from TikZ. The second distribution uses default color and plot marks. A background grid is also added with cells of size \(0.1\times0.1\). Finally, the charts are exported to a file in LaTeX format. Figure  empiricalchart-res shows the resulting chart.

Creating and customizing empirical distribution charts  [empiricalchart]

package charts;
import umontreal.ssj.rng.*;
import umontreal.ssj.randvar.*;
import umontreal.ssj.charts.*;
import java.util.Arrays;
import java.awt.Color;
public class EmpiricalChartTest {
private static double[] getPoints1() {
RandomVariateGen gen = new UniformGen(new LFSR113());
final int N = 10;
double[] data = new double[N];
for (int i = 0; i < N; i++)
data[i] = gen.nextDouble();
Arrays.sort(data);
return data;
}
private static double[] getPoints2() {
RandomVariateGen gen = new BetaGen(new LFSR113(), 3, 1);
final int N = 20;
double[] data = new double[N];
for (int i = 0; i < N; i++)
data[i] = gen.nextDouble();
Arrays.sort(data);
return data;
}
public static void main(String[] args) {
double[] data1 = getPoints1();
double[] data2 = getPoints2();
// Create a new chart with the previous data series.
EmpiricalChart chart = new EmpiricalChart(null, null, null, data1, data2);
// Data plots customizing
EmpiricalSeriesCollection collec = chart.getSeriesCollection();
collec.setMarksType(0, "square*");
collec.setColor(0, Color.MAGENTA);
chart.enableGrid(0.1, 0.1); // Enables grid
chart.toLatexFile("EmpiricalChartTest.tex", 12, 8);
}
}
A customized empirical distribution chart

The next example, given in Listing  histo1, shows how to plot a simple histogram. First, data is generated from a standard normal. Then the plot is customized: 80 bins are selected, and the range of the plot is set manually with bounds; the interval is \([-4, 4]\) for the \(x\)-coordinates, and \([0, 5000]\) for the \(y\)-coordinates. Finally, the histogram chart is viewed on the screen, then exported to file HistogramTest1.tex in LaTeX format. Figure  histo1-res displays the resulting chart.

Source code creating a simple histogram  [histo1]

package charts;
import umontreal.ssj.charts.*;
import umontreal.ssj.rng.*;
import umontreal.ssj.randvar.*;
import java.awt.Color;
public class HistogramTest1 {
private static double[] getData() {
NormalGen gen = new NormalGen(new LFSR113());
final int N = 100000;
double[] ad = new double[N];
for (int i = 0; i < N; i++)
ad[i] = gen.nextDouble();
return ad;
}
public static void main(String[] args) {
double[] data = getData();
HistogramChart chart;
chart = new HistogramChart("Standard Normal", null, null, data);
// Customizes the data plot
HistogramSeriesCollection collec = chart.getSeriesCollection();
collec.setBins(0, 80);
double[] bounds = { -4, 4, 0, 5000 };
chart.setManualRange(bounds);
chart.view(800, 500);
chart.toLatexFile("HistogramTest1.tex", 12, 8);
}
}
A simple histogram for the standard normal density

The next example, given in Listing  histochart, shows how to plot and customize histograms. First, the two histogram charts data1 and data2 are created. Then the data plots are customized: two colors are selected in the sRGB model from the java.awt.Color package. 40 bins are selected on the interval \([-6, 6]\) for the first histogram. The number of bins for the second histogram is set automatically. The range of the plot is set manually with bounds. Finally, the two histograms charts are exported to file HistogramChartTest.tex in LaTeX format. Figure  histochart-res displays the resulting chart.

Source code creating and customizing histograms.  [histochart]

package charts;
import umontreal.ssj.charts.*;
import umontreal.ssj.rng.*;
import umontreal.ssj.randvar.*;
import java.awt.Color;
public class HistogramChartTest {
private static double[] getPoints1() {
NormalGen gen = new NormalGen(new MRG32k3a(), 0, 2);
final int N = 100000;
double[] ad = new double[N];
for (int i = 0; i < N; i++)
ad[i] = gen.nextDouble();
return ad;
}
private static double[] getPoints2() {
ExponentialGen gen = new ExponentialGen(new MRG32k3a(), 1);
final int N = 100000;
double[] ad = new double[N];
for (int i = 0; i < N; i++)
ad[i] = gen.nextDouble();
return ad;
}
public static void main(String[] args) {
double[] data1 = getPoints1();
double[] data2 = getPoints2();
// Create a new chart with the previous data series.
HistogramChart chart = new HistogramChart(null, null, null, data1, data2);
// Customizes the data plots
HistogramSeriesCollection collec = chart.getSeriesCollection();
collec.setColor(0, new Color(255, 0, 0, 128));
collec.setColor(1, new Color(0, 255, 0, 128));
collec.setBins(0, 40, -6, 6);
// Define range bounds.
double[] bounds = { -6, 6, 0, 30000 };
chart.setManualRange00(bounds, true, true);
chart.toLatexFile("HistogramChartTest.tex", 12, 8);
}
}
A customized histogram chart

The next example, given in Listing  boxplot, shows how to create a box-and-whisker plot. First, two series of 1000 points are obtained from a lognormal distribution and from a Poisson distribution with \(\lambda=5\). These are passed to a BoxChart object, which creates the boxplot, which can be viewed on screen by executing the program. We find that the boxplot for the Poisson data (the box on the right of the chart) has median = 5 (the line inside the box), a mean = 5.009 (the center of the black circle) the first and the third quartiles at 3 and 6, while the lower and upper whiskers are at 0 and 10. Finally, there are outliers at 11 and 12 (the hollow circles) and extreme outliers (the triangle) at 13, outside the chart. We see that the Poisson data is skewed towards higher values. A similar description applies to the lognormal data (the box on the left of the chart), which is strongly skewed towards smaller values.

Source code creating a box-and-whisker plot.  [boxplot]

package charts;
import umontreal.ssj.charts.*;
import umontreal.ssj.randvar.*;
import umontreal.ssj.rng.*;
import java.io.*;
public class BoxTest {
public static void main(String[] args) throws IOException {
int count = 1000;
double[] data1 = new double[count];
double[] data2 = new double[count];
RandomStream stream = new LFSR113();
RandomVariateGen log = new LognormalGen(stream);
RandomVariateGen poi = new PoissonGen(stream, 5.0);
for (int i = 0; i < count; i++) {
data1[i] = log.nextDouble();
data2[i] = poi.nextDouble();
}
BoxChart bc = new BoxChart("Boxplot1", "Series", "Y", data1, data2);
bc.view(600, 400);
}
}
A box-plot

Function Documentation

◆ add() [1/5]

int umontreal.ssj.charts.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.

Definition at line 288 of file XYListSeriesCollection.java.

◆ add() [2/5]

int umontreal.ssj.charts.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 added to 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.

Definition at line 306 of file XYListSeriesCollection.java.

◆ add() [3/5]

int umontreal.ssj.charts.add ( double data[][])

Adds a data series into the series collection.

The input format of data is described in constructor XYListSeriesCollection(double[][] data).

Parameters
datainput data.
Returns
Integer that represent the number of point sets added to the current dataset.

Definition at line 348 of file XYListSeriesCollection.java.

◆ add() [4/5]

int umontreal.ssj.charts.add ( double data[][],
int numPoints )

Adds data series into the series collection.

The input format of data is described in constructor XYListSeriesCollection(double[][] data). Only the first numPoints of data (the first numPoints columns of the matrix) will be added to each new series.

Parameters
datainput data.
numPointsNumber of points to add for each new series
Returns
Integer that represent the number of point sets added to the current dataset.

Definition at line 363 of file XYListSeriesCollection.java.

◆ add() [5/5]

int umontreal.ssj.charts.add ( DoubleArrayList data)

Adds a data series into the series collection.

The input format of data is described in constructor XYListSeriesCollection (DoubleArrayList... data).

Parameters
datadata series.
Returns
Integer that represent the new point set’s position in the JFreeChart XYSeriesCollection object.

Definition at line 415 of file XYListSeriesCollection.java.

◆ disableAutoCompletion()

void umontreal.ssj.charts.disableAutoCompletion ( )

Disables auto completion option.

Default status is disabled.

Definition at line 506 of file XYListSeriesCollection.java.

◆ enableAutoCompletion()

void umontreal.ssj.charts.enableAutoCompletion ( )

Enables the auto completion option.

When this parameter is enabled, straight lines are used to approximate points on the chart bounds if the method isn’t able to display all points, because the user defined bounds are smaller than the most significant data point coordinate, for instance. It does not extrapolate the point sets, but simply estimates point coordinates on the curve at bound positions for a better visual rendering.

Definition at line 499 of file XYListSeriesCollection.java.

◆ getDashPattern()

String umontreal.ssj.charts.getDashPattern ( int series)

Returns the dash pattern associated with the seriesth data series.

Parameters
seriesseries index.
Returns
mark type.

Definition at line 540 of file XYListSeriesCollection.java.

◆ getMarksType()

String umontreal.ssj.charts.getMarksType ( int series)

Returns the mark type associated with the seriesth data series.

Parameters
seriesseries index.
Returns
mark type.

Definition at line 516 of file XYListSeriesCollection.java.

◆ getName()

String umontreal.ssj.charts.getName ( int series)

Gets the current name of the selected series.

Parameters
seriesseries index.
Returns
current name of the series.

Definition at line 467 of file XYListSeriesCollection.java.

◆ getPlotStyle()

String umontreal.ssj.charts.getPlotStyle ( int series)

Gets the current plot style for the selected series.

Parameters
seriesseries index.
Returns
current plot style.

Definition at line 573 of file XYListSeriesCollection.java.

◆ setDashPattern()

void umontreal.ssj.charts.setDashPattern ( int series,
String dashPattern )

Selects dash pattern for a data series.

It is possible to use all the dash options provided by the TikZ package: "<tt>solid</tt>", "<tt>dotted</tt>", "<tt>densely dotted</tt>", "<tt>loosely dotted</tt>", "<tt>dashed</tt>", "<tt>densely dashed</tt>", "<tt>loosely dashed</tt>" and "<tt>only marks</tt>". If "<tt>only marks</tt>" is chosen, then method setMarksType must be called to choose the marks (which are blank by default).

Parameters
seriesseries index.
dashPatterndash style.

Definition at line 556 of file XYListSeriesCollection.java.

◆ setMarksType()

void umontreal.ssj.charts.setMarksType ( int series,
String marksType )

Adds marks on the points of a data series.

It is possible to use any of the marks provided by the TikZ package, some of which are "<tt>*</tt>", "<tt>+</tt>" and "<tt>x</tt>". A blank character, used by default, disables marks. The PGF/TikZ documentation provides more information about placing marks on plots.

Parameters
seriesseries index.
marksTypemark type.

Definition at line 530 of file XYListSeriesCollection.java.

◆ setName()

void umontreal.ssj.charts.setName ( int series,
String name )

Sets the name of the selected series.

Parameters
seriesseries index.
namepoint set new name.

Definition at line 477 of file XYListSeriesCollection.java.

◆ setPlotStyle()

void umontreal.ssj.charts.setPlotStyle ( int series,
String plotStyle )

Selects the plot style for a given series.

It is possible to use all the plot options provided by the TikZ package. Some of which are: "<tt>sharp plot</tt>", which joins points with straight lines, "<tt>smooth</tt>", which joins points with a smoothing curve, "<tt>only marks</tt>", which does not join points, etc. The PGF/TikZ documentation provides more information about smooth plots, sharp plots and comb plots.

Parameters
seriesseries index.
plotStyleplot style.

Definition at line 589 of file XYListSeriesCollection.java.

◆ XYListSeriesCollection() [1/5]

umontreal.ssj.charts.XYListSeriesCollection ( )

Stores data used in a XYLineChart or in other related charts, and provides complementary tools to draw simple curves.

For example, one may add or remove plots series and modify plot style. It extends extends SSJXYSeriesCollection and is linked with the JFreeChart XYSeriesCollection class to store data plots, and linked with the JFreeChart XYLineAndShapeRenderer` to render the plot. Each series must contain enough points to plot a nice curve. It is recommended to use about 30 points. However, some rapidly varying functions may require many more points. It can be used to draw scatter plots.

*/ public class XYListSeriesCollection extends SSJXYSeriesCollection { protected String[] marksType; // marks on points (+, x, *...) protected String[] dashPattern; // line dashing (solid, dotted, densely dotted, loosely dotted, dashed, densely dashed, loosely dashed, only marks) protected String[] plotStyle; // plot style (lines, curves...) private boolean autoCompletion = false;

/** Creates a new XYListSeriesCollection instance with an empty dataset.

Definition at line 62 of file XYListSeriesCollection.java.

◆ XYListSeriesCollection() [2/5]

umontreal.ssj.charts.XYListSeriesCollection ( double data[][],
int numPoints )

Creates a new XYListSeriesCollection instance with default parameters and given points data.

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 set of points. Therefore, if the points represents curves to be plotted, data \([i][ ]\), \(i=0,…, n-1\), corresponds to \(n-1\) curves, all with the same \(x\)-coordinates. Only the first numPoints of data will be considered for each of the set of points.

Parameters
dataseries of point sets.
numPointsNumber of points to plot

Definition at line 154 of file XYListSeriesCollection.java.

◆ XYListSeriesCollection() [3/5]

umontreal.ssj.charts.XYListSeriesCollection ( double... data[][])

Creates a new XYListSeriesCollection instance with default parameters and given data series.

The input parameter data represents a set of plotting data.

For example, if one \(n\)-row matrix data1 is given as argument, then the first row data1 \([0]\) represents the

\(x\)-coordinate vector, and every other row data1 \([i], i=1,…, n-1\), represents a \(y\)-coordinate set for the points. Therefore matrix data1 \([i][j]\), \(i=0,…, n-1\), corresponds to \(n-1\) curves, all with the same \(x\)-coordinates.

                 However, one may want to plot several curves with
                 different

\(x\)-coordinates. In that case, one should give the curves 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 curves, data* \([0]\) being the \(x\)-coordinates, and data* \([1]\) the \(y\)-coordinates of the curves.

                However, we may also consider the sets of points above
                not as part of curves, but rather as several list of
                points.
Parameters
dataseries of point sets.

Definition at line 98 of file XYListSeriesCollection.java.

◆ XYListSeriesCollection() [4/5]

umontreal.ssj.charts.XYListSeriesCollection ( DoubleArrayList... data)

Creates a new XYListSeriesCollection instance with default parameters and given data.

The input parameter represents a set of data plots, the constructor will count the occurrence number \(Y\) of each value \(X\) in the DoubleArrayList, and plot the point \((X, Y)\). Each DoubleArrayList variable corresponds to a curve on the chart.

Parameters
dataseries of point sets.

Definition at line 195 of file XYListSeriesCollection.java.

◆ XYListSeriesCollection() [5/5]

umontreal.ssj.charts.XYListSeriesCollection ( XYSeriesCollection data)

Creates a new XYListSeriesCollection instance with default parameters and given data series.

The input parameter represents a set of plotting data. Each series of the given collection corresponds to a curve on the plot.

Parameters
dataseries of point sets.

Definition at line 250 of file XYListSeriesCollection.java.