Functional interface to the plot window manager
The interface is very much MATLAB-like.
If talkback is enabled the return values of command handlers are returned by the functions. If talkback is disabled, the return values are always None.
The plotting happens in a separate thread (process) so the plot windows remain responsive even if the main thread does some computation. No additional user intervention is needed (like calling some refresh function from time-to time).
An example will explain more than ten paragraphs of text:
import pyopus.wxmplplot.plotitf as pyopl
from numpy import arange, sin, cos, exp, pi
# Initialize the graphical thread. If it is already initialized this does
# nothing. After initialization a Control window pops up. When it is closed
# all plot windows are closed and the graphical thread exits. After that a
# new call to init() is needed to start the graphical thread.
pyopl.init()
# Create some x and y data
x = arange(0.0, 2*pi, 0.2)
y1 = sin(x)
y2 = cos(x)
y3 = exp(x/pi)
# Create a plot window (figure). This is now the active plot window.
# Tag (stored in f1) is assigned automatically by the system.
# Figure size is 600x400 pixels. The dpi value is used when the figure is
# saved to Postscript.
f1=pyopl.figure(None, windowTitle="Figure - single axes",
figpx=(600,400), dpi=100)
# Create axes in the active figure. Axes will take the whole area of the
# active figure. The return value (stored in ax1) is the axes tag.
# The tag is generated by the system.
ax1=pyopl.axes()
# Add first trace (x, y1). Solid line, points marked with o.
# Color is a (r,g,b) tuple of values between 0 and 1. The trace is labeled
# 'sin(x)'. See Matplotlib for other style options.
pyopl.plot(x, y1, '-o', label='sin(x)', color=(1,0,0))
# Hold on - next traces will not delete previous ones.
pyopl.hold(True)
# Add second trace. Red, points marked with x, no line. Trace is labeled
# 'cos(x)'.
pyopl.plot(x, y2, 'rx', label='cos(x)')
# Add third trace. Dashed, black, points marked with vertical lines.
# Label is 'exp(x/pi)'.
pyopl.plot(x, y3, '--k|', label='exp(x/pi)')
# Add legend.
pyopl.legend()
# Label axes, add title.
pyopl.xlabel('x-axis')
pyopl.ylabel('y-axis')
pyopl.title('Axes title. ')
# Turn on grid.
pyopl.grid(True)
# Disable hold. We are done adding new traces.
pyopl.hold(False)
# Enable active figure updates.
pyopl.repaintFigure(True)
Initializes the graphical thread and pops up the Control window. Closing the control window closes all plots and exits the graphical thread. To use graphics again a new call to init() is needed.
If the graphical therad is already running calling init() has no effect.
Calling convention: updateRCParams(dict)
Updates the rcParams structure of Matplotlib with the dictionary given by dict. Returns True on success.
Plots a trace on the active axes of the active plot window.
See the Matplotlib Axes.plot() method for details.
Plots a stem plot on the active axes of the active plot window.
See the Matplotlib Axes.stem() method for details.
Plots a trace on the active axes of the active plot window. Makes the scale of the x-axis logarithmic.
See the Matplotlib Axes.semilogx() method for details.
Plots a trace on the active axes of the active plot window. Makes the scale of the y-axis logarithmic.
See the Matplotlib Axes.semilogy() method for details.
Plots a trace on the active axes of the active plot window. Makes the scale of the x-axis and the y-axis logarithmic.
See the Matplotlib Axes.loglog() method for details.
Calling convention: setXAxisScale(type, ...)
Sets the type of the x-axis scale in the active axes of the active plot window. Possible values of type are linear, log, and symlog.
All remaining arguments are passed to the Matplotlib Axes.set_xscale() method.
See the Matplotlib Axes.set_xscale() method for details.
Calling convention: setYAxisScale(type, ...)
Sets the type of the y-axis scale in the active axes of the active plot window. Possible values of type are linear, log, and symlog.
All remaining arguments are passed to the Matplotlib Axes.set_yscale() method.
See the Matplotlib Axes.set_yscale() method for details.
Calling convention: grid(b, ...)
Turns the grid on/off (depending on b) for the active axes of the active plot window. All remaining arguments are passed to the Matplotlib Axes.grid() method.
See the Matplotlib Axes.grid() method for details.
Calling convention: xgridline(x =0.0, ymin =0.0, ymax =1.0, ...)
Draws a vertical grid line at x from ymin to ymax in the active axes of the active plot window. ymin and ymax are both in relative coordinates (between 0 and 1, 0 for bottom, 1 for top). All remaining arguments are passed to the Matplotlib Axes.axvline() method.
See the Matplotlib Axes.axvline() method for details.
Calling convention: ygridline(y =0.0, xmin =0.0, xmax =1.0, ...)
Draws a vertical grid line at y from xmin to xmax in the active axes of the active plot window. xmin and xmax are both in relative coordinates (between 0 and 1, 0 for left, 1 for right). All remaining arguments are passed to the Matplotlib Axes.axhline() method.
See the Matplotlib Axes.axhline() method for details.
Calling convention: arrow(x, y, dx, dy, ...)
Draws an arrow from (x, y) to (x*+*dx, y*+*dy) in the active axes of the actigve plot window. All remaining arguments are passed to the Matplotlib Axes.arrow() method.
See the Matplotlib Axes.arrow() method for details.
Returns the x-axis range for the active axes of the active plot window. The range is returned as a list with 2 members (low and high).
See the Matplotlib Axes.get_xlim() method for details.
Returns the y-axis range for the active axes of the active plot window. The range is returned as a list with 2 members (low and high).
See the Matplotlib Axes.get_ylim() method for details.
Returns the radial range for the active axes of the active plot window. Works only if axes are displaying a polar plot. The range is returned as a real number (maximal R).
See the Matplotlib PolarAxes.get_rmax() method for details.
Calling convention: setXlim(xmin, xmax)
Sets the x-axis limits for the active axes of the active plot window. The limits are specified with the xmin and the xmax argument. Any of the two arguments can be ommitted. This way only the specified limit is affected.
See the Matplotlib Axes.set_xlim() method for details.
Calling convention: setYlim(ymin, ymax)
Sets the y-axis limits for the active axes of the active plot window. The limits are specified with the ymin and the ymax argument. Any of the two arguments can be ommitted. This way only the specified limit is affected.
See the Matplotlib Axes.set_ylim() method for details.
Calling convention: setRlim(rmax)
Sets the R limit for the active axes of the active plot window to rmax. Works only if axes are displaying a polar plot.
See the Matplotlib PolarAxes.set_rmax() method for details.
Calling convention: autoscale(tight, scalex, scaley)
Autoscales the active axes of the active plot window. scalex and scaley are boolean flags specifying which axes to autoscale. If tight is True autoscaling is tight.
See the Matplotlib Axes.autoscale_view() method for details.
Calling convention: setXTicks(ticks, minor)
Sets the list of ticks for the x-axis. minor is False by default.
See the Matplotlib Axes.set_xticks() method for details.
Calling convention: setYTicks(ticks, minor)
Sets the list of ticks for the y-axis. minor is False by default.
See the Matplotlib Axes.set_yticks() method for details.
Calling convention: getXTicks(minor)
Returns the list of ticks for the x-axis. minor is False by default.
See the Matplotlib Axes.get_xticks() method for details.
Calling convention: getYTicks(minor)
Returns the list of ticks for the y-axis. minor is False by default.
See the Matplotlib Axes.get_yticks() method for details.
Displays a legend in the active axes of the active plot window. All arguments are passed to the Matplotlib Axes.legend() method.
See the Matplotlib Axes.legend() method for details.
Calling convention: xlabel(xlabel, ...)
Labels the x-axis in the active axes of the active plot window with the string given by xlabel. All remaining arguments are passed to the Matplotlib Axes.set_xlabel() method.
See the Matplotlib Axes.set_xlabel() method for details.
Calling convention: ylabel(ylabel, ...)
Labels the y-axis in the active axes of the active plot window with the string given by ylabel. All remaining arguments are passed to the Matplotlib Axes.set_ylabel() method.
See the Matplotlib Axes.set_ylabel() method for details.
Calling convention: title(title, ...)
Sets the title for the active axes of the active plot window to title. All remaining arguments are passed to the Matplotlib Axes.set_title() method.
See the Matplotlib Axes.set_title() method for details.
Calling convention: text(x, y, s, ...)
Prints a text given by s at coordinates x, y in the active axes of the active plot window. All remaining arguments are passed to the Matplotlib Axes.text() method.
See the Matplotlib Axes.text() method for details.
Calling convention: annotate(s, xy, xytext, ...)
Prints an annotation s at coordinates given by tuple xytext pointing to a point with coordinates xy in the active axes of the active plot window. All remaining arguments are passed to the Matplotlib Axes.annotate() method.
See the Matplotlib Axes.annotate() method for details.
Calling convention: figure(tag, windowTitle, show, inFront, figpx, dpi, figsize, ...)
Create a new plot window with tag given by tag. If a plot window with the same tag exists it becomes inaccessible through its tag. If no tag is given a tag is assigned automatically.
windowTitle specifies the title of the window.
If show is True (default) the window will be visible as soon as it is created.
If inFront is True (default) the window will show up on top of all other windows.
figsize is a tuple specifying the horizontal and vertical figure size in inches. dpi is used for obtaining the size in pixels (for the screen).
figpx is a tuple specifying the horizontal and vertical figure size in pixels. dpi is used for obtaining the figure size in inches (i.e. for saving the figure in a Postscript file). When specified, figpx overrides figsize.
All remaining arguments are passed to the constructor of the pyopus.wxmplitf.PlotFrame object which passes them on to the constructor of the pyopus.wxmplitf.Plotpanel object.
Returns the tag of the newly created plot window.
Sets the active plot window to be the window tagged with tag.
Returns True on success. On failure all plot windows become inactive.
Closes a plot window tagged with tag. If no tag is given, closes the active plot window.
Returns True on success.
Clears the contents of a plot window tagged with tag. If no tag is given, clears the contents of teh active plot window.
Returns True on success.
Shows (on is True) or hides the plot window tagged with tag. If tag is not given, shows/hides the active plot window.
Returns True on success.
Raises the plot window tagged with tag. If tag is not given, raises the active plot window.
Returns True on success.
Enables (on is True) or disables repainiting for the plot windows tagged with tag. If no tags are given enables/disables repainting for the active plot window.
Returns a list of boolean values where True indicates success.
Saves the contents of a plot window tagged with tag to a file named fileName. if no tag is given the contents of the active plot window are saved.
See the FigureCanvasWxAgg.print_figure() method. The available file types are listed in the FigureCanvasWxAgg.filetypes dictionary.
Returns True on success.
Sets the title of the active plot window’s canvas to title.
This title appears on the top of the canvas.
Sets the title of the active plot window to title.
This title appears in the title bar of the plot window.
Calling convention: axes(rect, ...)
Creates new axes in the active plot window at the position and with size given by the rect tuple (in relative coordinates). The tuple has the following members:
Defaults to (0.12, 0.12, 0.76, 0.76).
All remaining arguments are passed to the Matplotlib Figure.add_axes() method.
Returns the axes tag. If axes with the same specification already exist the corresponding tag is returned without creating new axes.
See the Matplotlib Figure.add_axes() method for details.
Calling convention: subplot(nv, nh, pos, ...)
Creates new axes in the active plot window with a MATLAB style subplot specification. The canvas is divided in nv rows of nh columns. The individual cells are numbered starting with 1 (top left) to nh (top right) and then continuing through the remaining rows to nv times nh at bottom right. *pos specifies the number of the cell that is assigned to the canvas.
All remaining arguments are passed to the Matplotlib Figure.add_subplot() method.
Returns the axes tag. If axes with the same specification already exist the corresponding tag is returned without creating new axes.
See the Matplotlib Figure.add_subplot() method for details.
Activates axes tagged with tag in the active plot window.
Returns True on success. On failure all axes in the active plot window become inactive.
Returns the tag corresponding to the active axes of the active plot window.
Returns None if no plot window is active or there are no active axes in the active plot window.
Returns the list of tags corresponding to all axes of the active plot window.
Returns None if no plot window is active.
Deletes the axes tagged with tag from the active plot window.
If tag is ommitted the active axes of the active plot window are deleted.
If the active axes are deleted no axes are made active and the active plot window has no active axes.
Returns True on success.
Clears the contents of the axes tagged with tag in the active plot window.
If tag is ommitted the active axes are cleared.
Returns True on success.
Sets the hold state for the active axes of the active plot window to on.
If the hold state is enabled (on is True) adding a new trace does not delete all previous traces from the axes.
See the Matplotlib Axes.hold() method for details.