Class XYLineChart
- java.lang.Object
-
- umontreal.iro.lecuyer.charts.XYChart
-
- umontreal.iro.lecuyer.charts.XYLineChart
-
- Direct Known Subclasses:
- YListChart
public class XYLineChart extends XYChart
This class provides tools to create and manage curve plots. Using theXYLineChartclass is the simplest way to produce curve plots only. EachXYLineChartobject is linked with aXYListSeriesCollectiondata set.
-
-
Constructor Summary
Constructors Constructor and Description XYLineChart()Initializes a new XYLineChart instance with an empty data set.XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, double[][]... data)Initializes a new XYLineChart instance with sets of points data.XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, double[][] data, int numPoints)Initializes a new XYLineChart instance with sets of points data.XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, double[][] data, int x, int y)Initializes a new XYLineChart instance using subsets of data.XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, DoubleArrayList... data)Initializes a new XYLineChart instance with data data.XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, XYSeriesCollection data)Initializes a new XYLineChart instance with data data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intadd(double[][] data)Adds the new collection of data series data into the series collection.intadd(double[][] data, int numPoints)Adds the new collection of data series data into the series collection.intadd(double[] x, double[] y)Adds a data series into the series collection.intadd(double[] x, double[] y, int numPoints)Adds a data series into the series collection.intadd(double[] x, double[] y, java.lang.String name, java.lang.String plotStyle)Adds a data series into the series collection.XYListSeriesCollectiongetSeriesCollection()Returns the chart's dataset.voidsetSeriesCollection(XYListSeriesCollection dataset)Links a new dataset to the current chart.voidsetTicksSynchro(int s)Synchronizes X-axis ticks to the s-th series x-values.java.lang.StringtoLatex(double width, double height)Exports the chart to a LATEX source code using PGF/TikZ.javax.swing.JFrameview(int width, int height)Displays chart on the screen using Swing.javax.swing.JFrameviewBar(int width, int height)Displays bar chart on the screen using Swing.-
Methods inherited from class umontreal.iro.lecuyer.charts.XYChart
disableGrid, enableGrid, getChartMargin, getJFreeChart, getTitle, getXAxis, getYAxis, setAutoRange, setAutoRange, setAutoRange00, setChartMargin, setLatexDocFlag, setManualRange, setManualRange, setManualRange00, setprobFlag, setTitle, toLatexFile
-
-
-
-
Constructor Detail
-
XYLineChart
public XYLineChart()
Initializes a new XYLineChart instance with an empty data set.
-
XYLineChart
public XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, double[][]... data)Initializes a new XYLineChart 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. The input parameter data represents a set 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 a y-coordinate set for a curve. 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.
- Parameters:
title- chart title.XLabel- Label on x-axis.YLabel- Label on y-axis.data- series of point sets.
-
XYLineChart
public XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, double[][] data, int numPoints)Initializes a new XYLineChart 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 set of points. Therefore matrix data[i][ ], i = 0,…, n - 1, corresponds to n - 1 curves, all with the same x-coordinates. However, only the first numPoints of data will be considered to plot each curve.- Parameters:
title- chart title.XLabel- Label on x-axis.YLabel- Label on y-axis.data- series of point sets.numPoints- Number of points to plot
-
XYLineChart
public XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, double[][] data, int x, int y)Initializes a new XYLineChart 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:
title- chart title.XLabel- Label on x-axis.YLabel- Label on y-axis.data- series of point sets.x- Index of data forming the x-coordinatesy- Index of data forming the y-coordinates
-
XYLineChart
public XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, DoubleArrayList... data)Initializes a new XYLineChart instance with data data. The input parameter data represents a set of plotting data. ADoubleArrayListfrom the Colt library is used to store the data. The description is similar to the constructorYListChartwith double[]... data.- Parameters:
title- chart title.XLabel- Label on x-axis.YLabel- Label on y-axis.data- series of point sets.
-
XYLineChart
public XYLineChart(java.lang.String title, java.lang.String XLabel, java.lang.String YLabel, XYSeriesCollection data)Initializes a new XYLineChart instance with data data. The input parameter data represents a set of plotting data.XYSeriesCollectionis a JFreeChart container class to store XY plots.- Parameters:
title- chart title.XLabel- Label on x-axis.YLabel- Label on y-axis.data- series collection.
-
-
Method Detail
-
add
public int add(double[] x, double[] y, java.lang.String name, java.lang.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- xi coordinates.y- yi coordinates.name- Name of the series.plotStyle- Plot style of the series.- Returns:
- Integer that represent the new point set's position in the JFreeChart XYSeriesCollection object.
-
add
public 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- xi coordinates.y- yi coordinates.- Returns:
- Integer that represent the new point set's position in the JFreeChart XYSeriesCollection object.
-
add
public 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- xi coordinates.y- yi coordinates.numPoints- Number of points to add- Returns:
- Integer that represent the new point set's position in the JFreeChart XYSeriesCollection object.
-
add
public int add(double[][] data)
Adds the new collection of data series data into the series collection. 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 matrix data[i][ ], i = 0,…, n - 1, corresponds to n - 1 curves, all with the same x-coordinates.- Parameters:
data- series of point sets.
-
add
public int add(double[][] data, int numPoints)Adds the new collection of data series data into the series collection. 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 matrix data[i][ ], i = 0,…, n - 1, corresponds to n - 1 curves, all with the same x-coordinates. However, only the first numPoints of data will be taken into account for the new series.- Parameters:
data- series of point sets.numPoints- Number of points to plot
-
getSeriesCollection
public XYListSeriesCollection getSeriesCollection()
Returns the chart's dataset.- Returns:
- the chart's dataset.
-
setSeriesCollection
public void setSeriesCollection(XYListSeriesCollection dataset)
Links a new dataset to the current chart.- Parameters:
dataset- new dataset.
-
setTicksSynchro
public void setTicksSynchro(int s)
Synchronizes X-axis ticks to the s-th series x-values.- Specified by:
setTicksSynchroin classXYChart- Parameters:
s- series used to define ticks.
-
view
public javax.swing.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.
-
viewBar
public javax.swing.JFrame viewBar(int width, int height)Displays bar chart on the screen using Swing. This method creates an application containing a bar 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:
width- frame width in pixels.height- frame height in pixels.- Returns:
- frame containing the bar chart.;
-
toLatex
public java.lang.String toLatex(double width, double height)Description copied from class:XYChartExports 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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG