7.4. pyopus.plotter.evalplotter — A PyQt5 and Matplotlib based simulation results plotter

Inheritance diagram of pyopus.plotter.evalplotter

A PyQt and Matplotlib based simulation results plotter (PyOPUS subsystem name: EvalPl)

This plotter takes the simulation results from a PerformanceEvaluator object.

Because this plotter depends on PyQt5 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 QPFigureCanvas 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 add_subplot() method of the plot window at axes creation
    • rectangle - the rectangle specification (tuple of 4 integers) passed to the add_axes() method of the plot window at axes creation
    • options - a dictionary of keyword arguments passed to the method that creates the axes
    • 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() method of the axes.

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() method of the axes)
class pyopus.plotter.evalplotter.EvalPlotter(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.