Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.charts
Class XYChart

    java.lang.Object
      umontreal.iro.lecuyer.charts.XYChart

Direct Known Subclasses:
  EmpiricalChart, HistogramChart, ScatterChart, XYLineChart

    public abstract class XYChart

extends Object

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 `SSJXYSeriesCollection` object representing the data, and the two `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.

Constructor Summary
`XYChart()`

Method Summary
`void` | `disableGrid()` Disables the background grid.
`void` | `enableGrid(double xstep, double ystep)` Puts a grid on the background.
`double` | `getChartMargin()` Returns the chart margin, which is the fraction by which the chart is enlarged on its borders.
`org.jfree.chart.JFreeChart` | `getJFreeChart()` Returns the `JFreeChart` object associated with this chart.
`String` | `getTitle()` Gets the current chart title.
`Axis` | `getXAxis()` Returns the chart's domain axis (x-axis) object.
`Axis` | `getYAxis()` Returns the chart's range axis (y-axis) object.
`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` | `setChartMargin(double margin)` Sets the chart margin to `margin`.
`void` | `setLatexDocFlag(boolean flag)` Flag to remove the `\documentclass` (and other) commands in the created LATEX files.
`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]`.
`abstract void` | `setTicksSynchro(int s)` Synchronizes x-axis ticks to the s-th series x-values.
`void` | `setTitle(String title)` Sets a title to this chart.
`abstract String` | `toLatex(double width, double height)` Transforms the chart into LATEX form and returns it as a `String`.
`abstract JFrame` | `view(int width, int height)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XYChart

    public XYChart()

Method Detail

### getJFreeChart

    public org.jfree.chart.JFreeChart getJFreeChart()

  Returns the `JFreeChart` object associated with this chart.

  Returns:
    the associated JFreeChart object.

### getXAxis

    public Axis getXAxis()

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

  Returns:
    chart's domain axis (x-axis) object.

### getYAxis

    public Axis getYAxis()

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

  Returns:
    chart's range axis (y-axis) object.

### view

    public abstract JFrame view(int width,
                                int height)

### getTitle

    public String getTitle()

  Gets the current chart title.

  Returns:
    Chart title.

### setTitle

    public void setTitle(String title)

  Sets a title to this chart. This title will appear on the chart displayed by method `view`.

  Parameters:
    `title` - chart title.

### setAutoRange

    public void 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:
    `right` - true if the x-values on the right of axis.
    `top` - true if the y-values on the top of axis.

### setAutoRange

    public void setAutoRange()

  The x and the y ranges of the chart are set automatically. The axes cross at point (0, 0).

### setManualRange

    public 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]`. 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:
    `range` - new axis ranges.
    `right` - true if the x-values on the right.
    `top` - true if the y-values on the top.

### setManualRange

    public void setManualRange(double[] range)

  Sets the x and y ranges of the chart, using the format: `range = [xmin, xmax, ymin, ymax]`. The axes cross at point (0, 0).

  Parameters:
    `range` - new axis ranges.

### getChartMargin

    public double getChartMargin()

  Returns the chart margin, which is the fraction by which the chart is enlarged on its borders. The default value is 0.05.

### setChartMargin

    public void setChartMargin(double margin)

  Sets the chart margin to `margin`. It is the fraction by which the chart is enlarged on its borders. Restriction: margin >= 0.

  Parameters:
    `margin` - margin percentage amount.

### setTicksSynchro

    public abstract void setTicksSynchro(int s)

  Synchronizes x-axis ticks to the s-th series x-values.

  Parameters:
    `s` - series.

### enableGrid

    public void 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:
    `xstep` - sets the step in the x-direction.
    `ystep` - sets the step in the y-direction.

### disableGrid

    public void disableGrid()

  Disables the background grid.

### toLatex

    public abstract String toLatex(double width,
                                   double height)

  Transforms the chart into LATEX form and returns it as a `String`.

### setLatexDocFlag

    public void 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`.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.