8.1. pyopus.visual.wxmplplotter — A wxPython and Matplotlib based simulation results plotter

Inheritance diagram of pyopus.visual.wxmplplotter

A wxPython and Matplotlib based simulation results plotter (PyOPUS subsystem name: WxMplPL)

This plotter takes the simulation results from a PerformanceEvaluator object.

Because this plotter depends on wxPython and Matplotlib it is not imported into the main PyOPUS module.

The plot windows and their contents are described by a dictionary with the following keys:

  • graphs - lists the plot windows and their axes
  • styles - lists the style masks for traces
  • traces - lists the traces that will be displayed on the axes of plot windows

The value of graphs is a dictionary with graph name for key. The value for every key is a dictionary describing a graph with the following members:

  • title - the title of the canvas displaying the graph

  • shape - a dictionary specifying the size of the plot window. It has the following members:

    • figsize - a tuple giving the horizontal and vertical size of the plot window in inches
    • figpx - a tuple giving the horizontal and vertical size of the plot window in pixels
    • dpi - a number specifying the dots-per-inch value for the plot window This value is used for converting figsize to pixels when the plot window is displayed on the screen.

    If both figsize and figpx are given, figpx takes precedence over figsize.

    If figpx is specified dpi is used for calculating the size of the figure in inches (used when a plot window is saved to a Postscript file).

    If figpx is not specified, dpi is used for convertion figsize to pixels. The obtained values specify the size of the plot window’s canvas.

    If dpi is not specified the default Matplotlib value is used.

    The contents of the shape dictionary are passed to the constructor of the PlotFrame object that corresponds to the plot window.

  • axes - a dictionary with axes name for key decribing the axes that reside in the plot window

    Every value in the axes dictionary describes one axes of the plot window. It is itself a dictionary with the following members:

    • subplot - the subplot specification (tuple of 3 integers) passed to the pyopus.wxmplplot.plotitf.subplot() function at axes creation
    • rectangle - the rectangle specification (tuple of 4 integers) passed to the pyopus.wxmplplot.plotitf.rectangle() function at axes creation
    • options - a dictionary passed to the axes creation function (pyopus.wxmplplot.plotitf.subplot() or pyopus.wxmplplot.plotitf.rectangle()) as keyword arguments at axes creation time
    • gridtype - type of grid for the axes. rect for rectilinear (default) or polar for polar grid.
    • xscale - a dictionary describing the type of the x-axis scale
    • yscale - a dictionary describing the type of the y-axis scale
    • xlimits - a tuple with two values specifying the lower and the upper limit for the x-axis scale
    • ylimits - a tuple with two values specifying the lower and the upper limit for the y-axis scale
    • xlabel - the label for the x-axis
    • ylabel - the label for the y-axis
    • title - the title for the axes
    • legend - a boolean flag indicating if legend should be displayed. False by default.
    • grid - a boolean flag indicating if gridlines should be displayed. False by default. `

    If both rectangle and subplot are specified, rectangle is used.

    Axis scale type (xscale and yscale) is a dictionary with the following members:

    • type - type of scale (linear, log, or symlog). Default is linear.
    • base - the base for the log scale (default is 10).
    • subticks - an array of log scale subticks (for base 10 this is range(10))
    • linthresh - linearity threshold for the symlog type of scale

    See the Axes.set_xscale() and Axes.set_yscale() methods in Matplotlib for more information.

The value of styles is a list of dictionaries. Every dictionary specifyes a style with the following dictionary members:

  • pattern - a tuple of 4 regular expressions for matching a trace to a style. The first member of the tuple matches the graph name, the second one matches the axes name, the third matches the corner name and the fourth matches the trace name. See the re standard Python module for the explanation of regular expressions.
  • style - a dictionary specifying style directives. Members of this dictionary are keyword arguments to the plot() function.

A trace style is determined by starting with no style directives. The styles list is traveversed and a style specified by the style member is applied if the pattern matches the graph, axes, corner, and trace name.

Style directives that appear later in the list override those that appear earlier. The final trace style is obtained by applying the style specified in the trace definition. This style overrides the style directives obtained with matching patterns from the styles list.

The traces member is a dictionary with trace name for key. Values are dictionaries with the following members:

  • graph - the name of the plot window in which the trace will appear
  • axes - the name of the axes in the plot window where trace will appear
  • xresult - the name of the performance measure in the PerformanceEvaluator object that is used for x-axis values
  • yresult - the name of the performance measure in the PerformanceEvaluator object that is used for y-axis values
  • corners - a list of corners for which the trace will be plotted. If ommitted the trace is plotted for all corners in which the xresult and yresult are evaluated.
  • style - a dictionary specifying the style directives (keyword arguments to the plot() function)
class pyopus.visual.wxmplplotter.WxMplPlotter(setup, performanceEvaluator, debug=0)

A class that plots the peformance measures from the perforamnceEvaluator object.

The way these measures are plotted is specified by setup.

If debug is greater than 0 debug messages are printed at standard output.

Objects of this class are callable with the following calling convention:

object(prefixText='', postfixText='', createPlots=True)

The title of every plot windows is the plot window name.

The title of every canvas is composed of prefixText, plot window title, and postfixText.

The createPlots is True the plot windows are created if they do not exist. If a plot window does not exist and it is not created then the traces that are supposed to be displayed by that plot window are not plotted.

If initializePlotting is True the plotting system is initialized (graphical thread is started) automatically when needed.

performanceEvaluator()

Returns the performance evaluator object specified when the plotter’s constructor was called.

Previous topic

8. pyopus.visual — Visualization of simulation results

Next topic

8.2. pyopus.visual.plotter — An optimization algorithm plugin for visualization of simulation results

This Page