Documentation of 'jhplot.Plot' Java class.
Plot
jhplot

Class Plot

  • All Implemented Interfaces:
    java.io.Serializable


    public class Plot
    extends JyplotVanilla
    implements java.io.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.show()
     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.
        Parameters:
        enableJFrame - true by default
    • Method Detail

      • export

        public void export(java.lang.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.
        Parameters:
        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,
                            java.awt.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.

        Eg:

        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)
         

        Parameters:
        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,
                                java.lang.String label,
                                java.awt.Color color,
                                java.awt.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,
                           java.lang.String[] kws)
        Sets the figure size. figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)
      • xticksa

        public void xticksa(PyObject[] args,
                            java.lang.String[] kws)
      • setp

        public void setp(PyObject[] args,
                         java.lang.String[] kws)
      • legendtest

        public void legendtest(PyObject[] args,
                               java.lang.String[] kws)
        Sets the legend labels and location.
        Parameters:
        args -
        kws -
      • savefig

        public void savefig(java.lang.String filename)
        This assumes
        Overrides:
        savefig in class JyplotVanilla
        Parameters:
        filename -
      • savefig

        public void savefig(java.lang.String filename,
                            int width,
                            int height)
        Overrides:
        savefig in class JyplotVanilla
      • plot

        public Dataset plot(PyObject[] args,
                            java.lang.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,
                           java.lang.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.
        Parameters:
        args -
        kws -
        Returns:
        A Dataset object
      • semilogx

        public Dataset semilogx(PyObject[] args,
                                java.lang.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(PyObject[] args,
                                java.lang.String[] kws)
      • loglog

        public Dataset loglog(PyObject[] args,
                              java.lang.String[] kws)
      • main

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

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

        public void draw(P1D p)
        Plot P1D object. Assume two dimensions. No errors.
        Parameters:
        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.
        Parameters:
        f1 -
        min -
        max -

DMelt 3.0 © DataMelt by jWork.ORG