7.4. pyopus.plotter.evalplotter
— A PyQt5 and Matplotlib based simulation results plotter¶
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 axesstyles
- lists the style masks for tracestraces
- 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 graphshape
- 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 inchesfigpx
- a tuple giving the horizontal and vertical size of the plot window in pixelsdpi
- a number specifying the dots-per-inch value for the plot window This value is used for convertingfigsize
to pixels when the plot window is displayed on the screen.
If both
figsize
andfigpx
are given,figpx
takes precedence overfigsize
.If
figpx
is specifieddpi
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 convertionfigsize
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 theQPFigureCanvas
object that corresponds to the plot window.axes
- a dictionary with axes name for key decribing the axes that reside in the plot windowEvery 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 theadd_subplot()
method of the plot window at axes creationrectangle
- the rectangle specification (tuple of 4 integers) passed to theadd_axes()
method of the plot window at axes creationoptions
- a dictionary of keyword arguments passed to the method that creates the axesgridtype
- type of grid for the axes.rect
for rectilinear (default) orpolar
for polar grid.xscale
- a dictionary describing the type of the x-axis scaleyscale
- a dictionary describing the type of the y-axis scalexlimits
- a tuple with two values specifying the lower and the upper limit for the x-axis scaleylimits
- a tuple with two values specifying the lower and the upper limit for the y-axis scalexlabel
- the label for the x-axisylabel
- the label for the y-axistitle
- the title for the axeslegend
- 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
andsubplot
are specified,rectangle
is used.Axis scale type (
xscale
andyscale
) is a dictionary with the following members:type
- type of scale (linear
,log
, orsymlog
). Default islinear
.base
- the base for the log scale (default is 10).subticks
- an array of log scale subticks (for base 10 this isrange(10)
)linthresh
- linearity threshold for thesymlog
type of scale
See the
Axes.set_xscale()
andAxes.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 there
standard Python module for the explanation of regular expressions.style
- a dictionary specifying style directives. Members of this dictionary are keyword arguments to theplot()
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 appearaxes
- the name of the axes in the plot window where trace will appearxresult
- the name of the performance measure in thePerformanceEvaluator
object that is used for x-axis valuesyresult
- the name of the performance measure in thePerformanceEvaluator
object that is used for y-axis valuescorners
- a list of corners for which the trace will be plotted. If ommitted the trace is plotted for all corners in which thexresult
andyresult
are evaluated.style
- a dictionary specifying the style directives (keyword arguments to theplot()
method of the axes)
-
class
pyopus.plotter.evalplotter.
EvalPlotter
(setup, performanceEvaluator, debug=0)[source]¶ 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.