Documentation of 'jhplot.Plot' Java class.

Class Plot

  • All Implemented Interfaces:

    public class Plotextends JyplotVanillaimplements Serializable
    Simple canvas to draw data. The syntax is similar to Matlab (actually matplotlib). It is based on jFreeChart. For more advanced canvaces, look at HPlot, HPlotJa. Basic usage (in Jython):
     j = Plot() j.plot([1,2,3,2]) j.title("Some random plot") j.savefig(file='/tmp/someplot.png', 300, 200) 
    Plots can vbe saved in png,jpg,eps,svg, and pdf formats.

    See Also:
    Serialized Form
    • Constructor Detail

      • Plot

        public Plot()
        Create a default canvas
      • Plot

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

      • export

        public void export(String file)
        Fast export of the canvas to an image file (depends on the extension, i.e. PNG, JPG, PDF, EPS, SVG). No questions will be asked, an existing file will be rewritten.
        file - Output file with the proper extension. If no extension, PNG file is assumed.
      • axhline

        public void axhline(float y,                    float xmin,                    float xmax,                    float linewidth,                    Color color)
        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

         axhline(y = 1) 

        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(double[] x,                        double[] y,                        double[] xerr,                        double[] yerr,                        String label,                        Color color,                        Color cerr,                        int capsize,                        boolean barsabove)
        Sets the figure size.

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

      • figure

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

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

        public Dataset plot(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(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(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
      • main

        public static void main(String[] args)
      • draw

        public void draw(double[] x,                 double[] y)
        Plot Y vs X. Same as plot(x,y).
        x - X values
        y - Y vlaues
      • draw

        public void draw(P1D p)
        Plot P1D object. Assume two dimensions. No errors.
        p - input P1D
      • draw

        public void draw(F1D f1,                 double min,                 double max)
        Plot F1D function. Min and Max values should be defined during the function initialisation.
        f1 -
        min -
        max -

DMelt 2.7 © DataMelt by jWork.ORG