Class Jyplot

  • All Implemented Interfaces:

    public class Jyplotextends JyplotVanillaimplements Serializable
    This is a wrapper for the jfreechart library that provides Matlab (actually matplotlib/pylab) syntax. It is designed to be used via Jython, but also simplifies creating charts in Java also.

    Basic usage (in Jython):

     j = Jylab() j.plot([1,2,3,2]) j.title("Some random plot") j.show() j.savefig(file='/tmp/someplot.png', 300, 200) 

    Jylab can create png,jpg,eps,svg, and pdf images directly. All except png and jpg require third party libraries.

    Technical overview:

    Each time a plot type command is called, a new dataset is created. There are rarely multiple series in a single dataset. A renderer is associated with each dataset, thus individual plots can be easily customised.

    Currently all plots use an XYPlot and compatible datasets (XYDataset). Category plots are currently not used, but might be in the future, if needed.

    See Also:
    Serialized Form
    • Constructor Detail

      • Jyplot

        public Jyplot(boolean enableJFrame)
        For headless systems, there is the option of disabling the GUI.
        enableJFrame - true by default
      • Jyplot

        public Jyplot()
    • Method Detail

      • axhline

        public void axhline(org.python.core.PyObject[] args,           String[] kws)
        Creates a horizontal line along the x axis.

        Jython documentation

                        axhline(y=0, xmin=0, xmax=1, **kwargs) 

        Draw a horizontal line at y from xmin to xmax. With the default values of xmin=0 and xmax=1, this line will always span the horizontal extent of the axes, regardless of the xlim settings, even if you change them, eg with the xlim command. That is, the horizontal extent is in axes coords: 0=left, 0.5=middle, 1.0=right but the y location is in data coordinates.

        kwargs are the same as kwargs to plot (however so far only "linewidth" and "color" are implemented) and can be used to control the line properties.


        draw a thick red hline at y=0 that spans the xrange

                 axhline(linewidth=4, color='r')         

        draw a default hline at y=1 that spans the xrange


        draw a default hline at y=.5 that spans the the middle half of the xrange

                 axhline(y=.5, xmin=0.25, xmax=0.75)         

        args - Main arguments e.g. axhline(y=0, xmin=0, xmax=1
        kws - Additional arguments e.g. color='r', linewidth=4
      • errorbar

        public Dataset errorbar(org.python.core.PyObject[] args,               String[] kws)
        Sets the figure size.

        errorbar(x, y, yerr=None, xerr=None, fmt='b-', ecolor=None, capsize=3, barsabove=False

      • figure

        public void figure(org.python.core.PyObject[] args,          String[] kws)
        Sets the figure size. figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)
      • xticksa

        public void xticksa(org.python.core.PyObject[] args,           String[] kws)
      • setp

        public void setp(org.python.core.PyObject[] args,        String[] kws)
      • legendtest

        public void legendtest(org.python.core.PyObject[] args,              String[] kws)
        Sets the legend labels and location.
        args -
        kws -
      • plot

        public Dataset plot(org.python.core.PyObject[] args,           String[] kws)
        Sets the figure size. errorbar(x, y, yerr=None, xerr=None, fmt='b-', ecolor=None, capsize=3, barsabove=False
      • bar

        public Dataset bar(org.python.core.PyObject[] args,          String[] kws)
        Plot an arbitrary number of bars (boxes)
          bar(left, height, width=0.8, bottom=0,      color=None, edgecolor=None, linewidth=None,      yerr=None, xerr=None, ecolor=None, capsize=3,      align='edge', orientation='vertical', log=False)   
        Make a bar plot with rectangles bounded by left, left+width, bottom, bottom+height (left, right, bottom and top edges) left, height, width, and bottom can be either scalars or sequences.
        args -
        kws -
        A Dataset object
      • semilogx

        public Dataset semilogx(org.python.core.PyObject[] args,               String[] kws)
        Make a semilog plot with log scaling on the x axis. The args to semilog x are the same as the args to plot. See help plot for more info. Optional keyword args supported are any of the kwargs supported by plot or set_xscale. Notable, for log scaling: basex: base of the logarithm subsx: the location of the minor ticks; None defaults to autosubs, which depend on the number of decades in the plot; see set_xscale for details
      • semilogy

        public Dataset semilogy(org.python.core.PyObject[] args,               String[] kws)
      • loglog

        public Dataset loglog(org.python.core.PyObject[] args,             String[] kws)
      • main

        public static void main(String[] args)

SCaVis 2.2 © jWork.ORG