Documentation of 'jhplot.WPlot' Java class.
WPlot
jhplot

Class WPlot



  • public class WPlot
    extends java.lang.Object
    Canvas to plot various DMelt data. The canvas is based on the Waterfloo package. One can plot scatter, histogram, polar, pie charts, real-time charts. Also supports for X-Y data points with errors on X and Y. Built-in "click-and-edit" support and publication-quality output to vector-based graphics formats for printing.
    • Constructor Summary

      Constructors 
      Constructor and Description
      WPlot()
      Construct a frame with a canvas.
      WPlot(int width, int height)
      Construct a frame with the plot.
      WPlot(java.lang.String title)
      Construct a frame with a canvas.
      WPlot(java.lang.String title, int width, int height)
      Construct a frame with the plot.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addLegend(int dataset, java.lang.String legend)
      Add a legend (displayed at the upper right) for the specified data set with the specified string.
      void addXTick(java.lang.String label, double position)
      Specify a tick mark for the X axis.
      void clear()
      Clear the plot of all data points.
      void clear(int dataset)
      Clear the plot of data points in the specified dataset.
      void clearLegends()
      Clear all legends.
      void doc()
      Show online documentation.
      void draw(double[] x, double[] y)
      Draw a single data set as marks (default).
      void draw(double[] x, double[] y, java.lang.String opt)
      Draw X-Y data.
      void draw(F1D f1d)
      Draw a F1D function.
      void draw(F1D f1d, java.lang.String opt)
      Draw a function.
      void draw(H1D h1)
      Draw H1D histograms
      void draw(P0D p0d)
      Draw P0D array as a pie chart.
      void draw(P0I p0d)
      Draw P0I array as a pie chart.
      void draw(P1D p1d)
      Draw P1D array in X-Y space.
      void draw(P1D p1d, java.lang.String opt)
      Draw P1D array in X-Y space.
      void drawContour(P1D p1d)
      Draw a s
      void export(java.lang.String f)
      Fast export of the canvas to an image file (depends on the extension, i.e.
      boolean getAntiAlias()
      Get antialiasing for the graphics of the current plot
      GJGraphContainer getContainer()
      Get the graph container.
      WPlotFrame getFrame()
      Get the frame with the plot.
      GJGraph getGraph()
      Get the graph with the plot.
      GJPlotInterface getPlotInterface()
      Get the graph with the plot.
      static void main(java.lang.String[] args) 
      void setAntiAlias(boolean setit)
      Set antialiasing for the graphics of the current plot
      void setAutoRange()
      Rescale so that the data that is currently plotted just fits.
      void setAutoRange(boolean auto)
      Rescale so that the data that is currently plotted just fits.
      void setBackground(java.awt.Color c)
      Set background for the plot.
      void setFontAxis(java.awt.Font f)
      Sets font for small ticks on X and Y axis.
      void setForeground(java.awt.Color foreground)
      Set the foreground color.
      void setGrid(boolean b)
      Sets whether or not using grid lines.
      void setGTitle(java.lang.String title)
      Set global title for this plot.
      void setLabelFont(java.awt.Font name)
      Set the label font, which is used for axis labels and legend labels.
      void setName(java.lang.String label)
      Set subtitle of the plot.
      void setNameX(java.lang.String label)
      Set the label for the X (horizontal) axis.
      void setNameY(java.lang.String label)
      Set the label for the Y (vertical) axis.
      void setRange(double minX, double maxX, double minY, double maxY)
      Sets the range (min-max) displayed on X and Y
      void setRange(int axis, double min, double max)
      Sets the range (min-max) displayed on the axis.
      void setTitleFont(java.lang.String name)
      Set font of the title.
      void setXLog(boolean xlog)
      Specify whether the X axis is drawn with a logarithmic scale.
      void setYLog(boolean ylog)
      Specify whether the Y axis is drawn with a logarithmic scale.
      void setYRange(double min, double max)
      Set the Y (vertical) range of the plot.
      void update()
      Repaint the plot and update all graphics.
      void visible()
      Show the frame.
      void visible(boolean showIt)
      Show the frame or not?
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WPlot

        public WPlot()
        Construct a frame with a canvas. Default: do not show it.
      • WPlot

        public WPlot(java.lang.String title)
        Construct a frame with a canvas. Default: do not show it.
        Parameters:
        title -
      • WPlot

        public WPlot(int width,
                     int height)
        Construct a frame with the plot. Do not show it.
        Parameters:
        width - frame width
        height - frame height
      • WPlot

        public WPlot(java.lang.String title,
                     int width,
                     int height)
        Construct a frame with the plot. Do not show it.
        Parameters:
        title - i Title
        width - frame width
        height - frame height
    • Method Detail

      • setAntiAlias

        public void setAntiAlias(boolean setit)
        Set antialiasing for the graphics of the current plot
        Parameters:
        setit - true if antialiasing is set
      • getAntiAlias

        public boolean getAntiAlias()
        Get antialiasing for the graphics of the current plot
        Returns:
        true if antialiasing is set
      • setFontAxis

        public void setFontAxis(java.awt.Font f)
        Sets font for small ticks on X and Y axis.
        Parameters:
        f - Font
      • setBackground

        public void setBackground(java.awt.Color c)
        Set background for the plot.
        Parameters:
        c - background color.
      • setGTitle

        public void setGTitle(java.lang.String title)
        Set global title for this plot.
        Parameters:
        title - plot title
      • addLegend

        public void addLegend(int dataset,
                              java.lang.String legend)
        Add a legend (displayed at the upper right) for the specified data set with the specified string. Short strings generally fit better than long strings. If the string is empty, or the argument is null, then no legend is added.
        Parameters:
        dataset - The dataset index.
        legend - The label for the dataset.
        See Also:
        #renameLegend(int, String)
      • addXTick

        public void addXTick(java.lang.String label,
                             double position)
        Specify a tick mark for the X axis. The label given is placed on the axis at the position given by position. If this is called once or more, automatic generation of tick marks is disabled. The tick mark will appear only if it is within the X range.
        Parameters:
        label - The label for the tick mark.
        position - The position on the X axis.
      • clear

        public void clear()
        Clear the plot of all data points.
      • clearLegends

        public void clearLegends()
        Clear all legends. This will show up on the next redraw.
      • setForeground

        public void setForeground(java.awt.Color foreground)
        Set the foreground color.
        Parameters:
        foreground - The foreground color.
      • setLabelFont

        public void setLabelFont(java.awt.Font name)
        Set the label font, which is used for axis labels and legend labels. The font names understood are those understood by java.awt.Font.decode().
        Parameters:
        name - font name.
      • setTitleFont

        public void setTitleFont(java.lang.String name)
        Set font of the title.
        Parameters:
        name - A font name.
      • setNameX

        public void setNameX(java.lang.String label)
        Set the label for the X (horizontal) axis.
        Parameters:
        label - The label.
      • setXLog

        public void setXLog(boolean xlog)
        Specify whether the X axis is drawn with a logarithmic scale. If you would like to have the X axis drawn with a logarithmic axis, then setXLog(true) should be called before adding any data points.
        Parameters:
        xlog - If true, logarithmic axis is used.
      • setRange

        public void setRange(double minX,
                             double maxX,
                             double minY,
                             double maxY)
        Sets the range (min-max) displayed on X and Y
        Parameters:
        minX - minimum value on the X axis
        maxX - maximum value on the X axis
        minY - minimum value on the Y axis
        maxY - maximum value on the Y axis
      • setRange

        public void setRange(int axis,
                             double min,
                             double max)
        Sets the range (min-max) displayed on the axis.
        Parameters:
        axis - defines to which axis this function applies:
        0 means X,
        1 means Y.
        min - minimum value on the axis
        max - maximum value on the axis
      • setNameY

        public void setNameY(java.lang.String label)
        Set the label for the Y (vertical) axis.
        Parameters:
        label - The label.
      • setName

        public void setName(java.lang.String label)
        Set subtitle of the plot.
        Parameters:
        label - The label.
      • setYLog

        public void setYLog(boolean ylog)
        Specify whether the Y axis is drawn with a logarithmic scale. If you would like to have the Y axis drawn with a logarithmic axis, then setYLog(true) should be called before adding any data points.
        Parameters:
        ylog - If true, logarithmic axis is used.
      • setYRange

        public void setYRange(double min,
                              double max)
        Set the Y (vertical) range of the plot. If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn. If min and max are identical, then the range is arbitrarily spread by 0.1.
        Parameters:
        min - The bottom extent of the range.
        max - The top extent of the range.
      • draw

        public void draw(double[] x,
                         double[] y)
        Draw a single data set as marks (default).
        Parameters:
        x - array of x values
        y - array of y values
      • clear

        public void clear(int dataset)
        Clear the plot of data points in the specified dataset. This calls repaint() to request an update of the display.
        Parameters:
        dataset - The dataset to clear.
      • setAutoRange

        public void setAutoRange()
        Rescale so that the data that is currently plotted just fits.
      • setAutoRange

        public void setAutoRange(boolean auto)
        Rescale so that the data that is currently plotted just fits.
        Parameters:
        auto - if true, then autorange
      • update

        public void update()
        Repaint the plot and update all graphics.
      • setGrid

        public void setGrid(boolean b)
        Sets whether or not using grid lines. Grid lines are lines drawn from tick to tick. They can be enabled/disabled per axis.
        Parameters:
        b - true if shown
      • draw

        public void draw(H1D h1)
        Draw H1D histograms
        Parameters:
        h1 - H1D histogram to be shown.
      • draw

        public void draw(P0D p0d)
        Draw P0D array as a pie chart.
        Parameters:
        p0d - P0D object to show
      • draw

        public void draw(P0I p0d)
        Draw P0I array as a pie chart.
        Parameters:
        p0d - P0D object to show
      • draw

        public void draw(P1D p1d)
        Draw P1D array in X-Y space. If errors are included to P1D, they will be shown. Second-level error is not supported.
        Parameters:
        p1d - X-Y + error data
      • draw

        public void draw(double[] x,
                         double[] y,
                         java.lang.String opt)
        Draw X-Y data. Data can be plotted in a polar coordinates using the options PolarBar, PolarLine, PolarScatter, PolarStem. Also, one can show as bars and lines.
        Parameters:
        x - X data
        y - Y data
        opt - option for how to plot? Options can be: PolarBar,
        PolarLine,
        PolarScatter,
        PolarStem,
        Bar,
        Line
        . If none is given, the usual symbols in cartesian coordinate is assumed.
      • draw

        public void draw(F1D f1d,
                         java.lang.String opt)
        Draw a function. Data can be plotted in polar coordinates using the options: PolarBar, PolarLine, PolarScatter, PolarStem. Also, one can show as Bars or Scatter.
        Parameters:
        f1d - a function
        opt - option for how to plot? Options can be: PolarBar,
        PolarLine,
        PolarScatter,
        PolarStem,
        Bar,
        Scatter
        . If none is given, the usual X-Y coordinates are assumed.
      • draw

        public void draw(F1D f1d)
        Draw a F1D function.
        Parameters:
        f1d - a function
      • draw

        public void draw(P1D p1d,
                         java.lang.String opt)
        Draw P1D array in X-Y space. If errors are included to P1D, they will be shown. Second-level error is not supported. Data can be plotted in a polar coordinates using the options PolarBar, PolarLine, PolarScatter, PolarStem. Also, one can show as bars.
        Parameters:
        p1d - data in X and Y plus error.
        opt - how to plot? Options can be:
        PolarBar,
        PolarLine,
        PolarScatter,
        PolarStem,
        Bar,
        Line
        If none is given, the usual X-Y coordinates are assumed.
      • getFrame

        public WPlotFrame getFrame()
        Get the frame with the plot.
      • getPlotInterface

        public GJPlotInterface getPlotInterface()
        Get the graph with the plot.
        Returns:
        interface graph
      • getGraph

        public GJGraph getGraph()
        Get the graph with the plot.
        Returns:
        graph
      • getContainer

        public GJGraphContainer getContainer()
        Get the graph container.
      • visible

        public void visible(boolean showIt)
        Show the frame or not?
        Parameters:
        showIt - true if should be shown
      • visible

        public void visible()
        Show the frame.
      • drawContour

        public void drawContour(P1D p1d)
        Draw a s
        Parameters:
        p1d -
      • export

        public void export(java.lang.String f)
        Fast export of the canvas to an image file (depends on the extension, i.e. PNG, PDF, EPS, PS, SVG). Images can be saved to files with extension ".gz" (compressed SVG). Also, image can be saved to PDE format. No questions will be asked, an existing file will be rewritten. If
        Parameters:
        f - Output file with the proper extension. If no extension, PNG file is assumed. Other formats are PNG, PDF, EPS, PS, SVG.
      • doc

        public void doc()
        Show online documentation.
      • main

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

DMelt 3.0 © DataMelt by jWork.ORG