Class Jyplot
- java.lang.Object
-
- jyplot.JyplotVanilla
-
- jyplot.Jyplot
-
- All Implemented Interfaces:
- java.io.Serializable
public class Jyplot extends JyplotVanilla implements java.io.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 Summary
Constructors Constructor and Description Jyplot()Jyplot(boolean enableJFrame)For headless systems, there is the option of disabling the GUI.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaxhline(PyObject[] args, java.lang.String[] kws)Creates a horizontal line along the x axis.Datasetbar(PyObject[] args, java.lang.String[] kws)Plot an arbitrary number of bars (boxes)Dataseterrorbar(PyObject[] args, java.lang.String[] kws)Sets the figure size.voidfigure(PyObject[] args, java.lang.String[] kws)Sets the figure size.voidlegendtest(PyObject[] args, java.lang.String[] kws)Sets the legend labels and location.Datasetloglog(PyObject[] args, java.lang.String[] kws)static voidmain(java.lang.String[] args)Datasetplot(PyObject[] args, java.lang.String[] kws)Sets the figure size.voidsavefig(java.lang.String filename)This assumesvoidsavefig(java.lang.String filename, int width, int height)Datasetsemilogx(PyObject[] args, java.lang.String[] kws)Make a semilog plot with log scaling on the x axis.Datasetsemilogy(PyObject[] args, java.lang.String[] kws)voidsetp(PyObject[] args, java.lang.String[] kws)voidxticksa(PyObject[] args, java.lang.String[] kws)-
Methods inherited from class jyplot.JyplotVanilla
axis, bar, bar, bar, bar, bar, clf, color, color, color, color, connect, difference, drawToGraphics2D, errorbar, getChart, getChart, getChartPanelMap, getChartToPanelMap, getColor, getCols, getFrame, getJpanel, getRows, grid, gridx, gridy, hist, hist, hist, label, legend, linecolor, linestyle, linewidth, loglog, loglog, plot, plot, plot, plot, setAntiAlias, setBackgColor, setChart, setChartToPanelMap, setDomainSpace, setFrame, setJpanel, setQuitOnWindowClose, setRangeSpace, setShapesVisible, show, show, subplot, subplot, text, title, title, xlabel, xlim, xticks, xticks, ylabel, ylim, yticks
-
-
-
-
Constructor Detail
-
Jyplot
public Jyplot(boolean enableJFrame)
For headless systems, there is the option of disabling the GUI.- Parameters:
enableJFrame- true by default
-
Jyplot
public Jyplot()
-
-
Method Detail
-
axhline
public void axhline(PyObject[] args, java.lang.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.
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=1kws- Additional arguments e.g. color='r', linewidth=4
-
errorbar
public Dataset errorbar(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
-
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:
savefigin classJyplotVanilla- Parameters:
filename-
-
savefig
public void savefig(java.lang.String filename, int width, int height)- Overrides:
savefigin classJyplotVanilla
-
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
-
main
public static void main(java.lang.String[] args)
-
-
DMelt 3.0 © DataMelt by jWork.ORG