pyPenred’s API

class pyPenred.Figure(figsize=None, dpi=None, *, facecolor=None, edgecolor=None, linewidth=0.0, frameon=None, subplotpars=None, tight_layout=None, constrained_layout=None, layout=None, **kwargs)[source]

Bases: FigureBase

The top level container for all the plot elements.

See matplotlib.figure for an index of class methods.

Variables:
  • patch – The .Rectangle instance representing the figure background patch.

  • suppressComposite – For multiple images, the figure will make composite images depending on the renderer option_image_nocomposite function. If suppressComposite is a boolean, this will override the renderer.

__init__(figsize: tuple[float, float] | tuple[float, float, Literal['in', 'cm', 'px']] | None = None, dpi: float | None = None, *, facecolor: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None = None, edgecolor: tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None = None, linewidth: float = 0.0, frameon: bool | None = None, subplotpars: SubplotParams | None = None, tight_layout: bool | dict[str, Any] | None = None, constrained_layout: bool | dict[str, Any] | None = None, layout: Literal['constrained', 'compressed', 'tight'] | LayoutEngine | None = None, **kwargs) → None[source]
Parameters:
  • figsize (tuple[float, float] | tuple[float, float, Literal['in', 'cm', 'px']] | None) –

    The figure dimensions. This can be

    • a tuple (width, height, unit), where unit is one of “in” (inch), “cm” (centimenter), “px” (pixel).

    • a tuple (width, height), which is interpreted in inches, i.e. as (width, height, "in").

    One of width or height may be None; the respective value is taken from :rc:`figure.figsize`.

  • dpi (float | None) – Dots per inch.

  • facecolor (tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None) – The figure patch facecolor.

  • edgecolor (tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] | None) – The figure patch edge color.

  • linewidth (float) – The linewidth of the frame (i.e. the edge linewidth of the figure patch).

  • frameon (bool | None) – If False, suppress drawing the figure background patch.

  • subplotpars (SubplotParams | None) – Subplot parameters. If not given, the default subplot parameters :rc:`figure.subplot.*` are used.

  • tight_layout (bool | dict[str, Any] | None) –

    Whether to use the tight layout mechanism. See .set_tight_layout.

    Discouraged

    The use of this parameter is discouraged. Please use layout='tight' instead for the common case of tight_layout=True and use .set_tight_layout otherwise.

  • constrained_layout (bool | dict[str, Any] | None) –

    This is equal to layout='constrained'.

    Discouraged

    The use of this parameter is discouraged. Please use layout='constrained' instead.

  • layout (Literal['constrained', 'compressed', 'tight'] | LayoutEngine | None) –

    The layout mechanism for positioning of plot elements to avoid overlapping Axes decorations (labels, ticks, etc). Note that layout managers can have significant performance penalties.

    • ’constrained’: The constrained layout solver adjusts Axes sizes to avoid overlapping Axes decorations. Can handle complex plot layouts and colorbars, and is thus recommended.

      See constrainedlayout_guide for examples.

    • ’compressed’: uses the same algorithm as ‘constrained’, but removes extra space between fixed-aspect-ratio Axes. Best for simple grids of Axes.

    • ’tight’: Use the tight layout mechanism. This is a relatively simple algorithm that adjusts the subplot parameters so that decorations do not overlap.

      See tight_layout_guide for examples.

    • ’none’: Do not use a layout engine.

    • A .LayoutEngine instance. Builtin layout classes are .ConstrainedLayoutEngine and .TightLayoutEngine, more easily accessible by ‘constrained’ and ‘tight’. Passing an instance allows third parties to provide their own layout engine.

    If not given, fall back to using the parameters tight_layout and constrained_layout, including their config defaults :rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.

  • **kwargs (.Figure properties, optional) – Properties: agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: float or None animated: bool canvas: FigureCanvas clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None constrained_layout: unknown constrained_layout_pads: unknown dpi: float edgecolor: :mpltype:`color` facecolor: :mpltype:`color` figheight: float figure: unknown figwidth: float frameon: bool gid: str in_layout: bool label: object layout_engine: {‘constrained’, ‘compressed’, ‘tight’, ‘none’, .LayoutEngine, None} linewidth: number mouseover: bool path_effects: list of .AbstractPathEffect picker: None or bool or float or callable rasterized: bool size_inches: (float, float) or float sketch_params: (scale: float, length: float, randomness: float) snap: bool or None tight_layout: unknown transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float

Return type:

None

add_axobserver(func)[source]

Whenever the Axes state change, func(self) will be called.

Return type:

None

property axes

List of Axes in the Figure. You can access and modify the Axes in the Figure through this list.

Do not modify the list itself. Instead, use ~Figure.add_axes, ~.Figure.add_subplot or ~.Figure.delaxes to add or remove an Axes.

Note: The .Figure.axes property and ~.Figure.get_axes method are equivalent.

clear(keep_observers=False)[source]

Clear the figure.

Parameters:

keep_observers (bool) – Set keep_observers to True if, for example, a gui widget is tracking the Axes in the figure.

Return type:

None

property dpi

The resolution in dots per inch.

draw(renderer)[source]

Draw the Artist (and its children) using the given renderer.

This has no effect if the artist is not visible (.Artist.get_visible returns False).

Parameters:

renderer (~matplotlib.backend_bases.RendererBase subclass.)

Notes

This method is overridden in the Artist subclasses.

draw_artist(a)[source]

Draw .Artist a only.

Return type:

None

draw_without_rendering()[source]

Draw the figure with no output. Useful to get the final size of artists that require a draw before their size is known (e.g. text).

Return type:

None

figimage(X, xo=0, yo=0, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, origin=None, resize=False, *, colorizer=None, **kwargs)[source]

Add a non-resampled image to the figure.

The image is attached to the lower or upper left corner depending on origin.

Parameters:
  • X (ArrayLike) –

    The image data. This is an array of one of the following shapes:

    • (M, N): an image with scalar data. Color-mapping is controlled by cmap, norm, vmin, and vmax.

    • (M, N, 3): an image with RGB values (0-1 float or 0-255 int).

    • (M, N, 4): an image with RGBA values (0-1 float or 0-255 int), i.e. including transparency.

  • xo (int) – The x/y image offset in pixels.

  • yo (int) – The x/y image offset in pixels.

  • alpha (float | None) – The alpha blending value.

  • cmap (str | Colormap | None) –

    The Colormap instance or registered colormap name used to map scalar data to colors.

    This parameter is ignored if X is RGB(A).

  • norm (str | Normalize | None) –

    The normalization method used to scale scalar data to the [0, 1] range before mapping to colors using cmap. By default, a linear scaling is used, mapping the lowest value to 0 and the highest to 1.

    If given, this can be one of the following:

    • An instance of .Normalize or one of its subclasses (see colormapnorms).

    • A scale name, i.e. one of “linear”, “log”, “symlog”, “logit”, etc. For a list of available scales, call matplotlib.scale.get_scale_names(). In that case, a suitable .Normalize subclass is dynamically generated and instantiated.

    This parameter is ignored if X is RGB(A).

  • vmin (float | None) –

    When using scalar data and no explicit norm, vmin and vmax define the data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data. It is an error to use vmin/vmax when a norm instance is given (but using a str norm name together with vmin/vmax is acceptable).

    This parameter is ignored if X is RGB(A).

  • vmax (float | None) –

    When using scalar data and no explicit norm, vmin and vmax define the data range that the colormap covers. By default, the colormap covers the complete value range of the supplied data. It is an error to use vmin/vmax when a norm instance is given (but using a str norm name together with vmin/vmax is acceptable).

    This parameter is ignored if X is RGB(A).

  • origin (Literal['upper', 'lower'] | None) – Indicates where the [0, 0] index of the array is in the upper left or lower left corner of the Axes.

  • resize (bool) – If True, resize the figure to match the given image size.

  • colorizer (Colorizer | None) –

    The Colorizer object used to map color to data. If None, a Colorizer object is created from a norm and cmap.

    This parameter is ignored if X is RGB(A).

  • **kwargs – Additional kwargs are .Artist kwargs passed on to .FigureImage.

Return type:

FigureImage

Notes

figimage complements the Axes image (~matplotlib.axes.Axes.imshow) which will be resampled to fit the current Axes. If you want a resampled image to fill the entire figure, you can define an ~matplotlib.axes.Axes with extent [0, 0, 1, 1].

Examples

f = plt.figure()
nx = int(f.get_figwidth() * f.dpi)
ny = int(f.get_figheight() * f.dpi)
data = np.random.random((ny, nx))
f.figimage(data)
plt.show()
get_axes() → list[Axes]

List of Axes in the Figure. You can access and modify the Axes in the Figure through this list.

Do not modify the list itself. Instead, use ~Figure.add_axes, ~.Figure.add_subplot or ~.Figure.delaxes to add or remove an Axes.

Note: The .Figure.axes property and ~.Figure.get_axes method are equivalent.

Return type:

list[Axes]

get_constrained_layout()[source]

Return whether constrained layout is being used.

See constrainedlayout_guide.

Return type:

bool

get_constrained_layout_pads(relative=False)[source]

[Deprecated] Get padding for constrained_layout.

Returns a list of w_pad, h_pad in inches and wspace and hspace as fractions of the subplot. All values are None if constrained_layout is not used.

See constrainedlayout_guide.

Parameters:

relative (bool) – If True, then convert from inches to figure relative.

Return type:

tuple[float, float, float, float]

Notes

Deprecated since version 3.6: Use fig.get_layout_engine().get() instead.

get_dpi()[source]

Return the resolution in dots per inch as a float.

Return type:

float

get_figheight()[source]

Return the figure height in inches.

Return type:

float

get_figwidth()[source]

Return the figure width in inches.

Return type:

float

get_layout_engine()[source]
Return type:

LayoutEngine | None

get_size_inches()[source]

Return the current size of the figure in inches.

Returns:

The size (width, height) of the figure in inches.

Return type:

ndarray

See also

matplotlib.figure.Figure.set_size_inches, matplotlib.figure.Figure.get_figwidth, matplotlib.figure.Figure.get_figheight

Notes

The size in pixels can be obtained by multiplying with Figure.dpi.

get_tight_layout()[source]

Return whether .Figure.tight_layout is called when drawing.

Return type:

bool

ginput(n=1, timeout=30, show_clicks=True, mouse_add=MouseButton.LEFT, mouse_pop=MouseButton.RIGHT, mouse_stop=MouseButton.MIDDLE)[source]

Blocking call to interact with a figure.

Wait until the user clicks n times on the figure, and return the coordinates of each click in a list.

There are three possible interactions:

  • Add a point.

  • Remove the most recently added point.

  • Stop the interaction and return the points added so far.

The actions are assigned to mouse buttons via the arguments mouse_add, mouse_pop and mouse_stop.

Parameters:
  • n (int) – Number of mouse clicks to accumulate. If negative, accumulate clicks until the input is terminated manually.

  • timeout (float) – Number of seconds to wait before timing out. If zero or negative will never time out.

  • show_clicks (bool) – If True, show a red cross at the location of each click.

  • mouse_add (MouseButton) – Mouse button used to add points.

  • mouse_pop (MouseButton) – Mouse button used to remove the most recently added point.

  • mouse_stop (MouseButton) – Mouse button used to stop input.

Returns:

A list of the clicked (x, y) coordinates.

Return type:

list[tuple[int, int]]

Notes

The keyboard can also be used to select points in case your mouse does not have one or more of the buttons. The delete and backspace keys act like right-clicking (i.e., remove last point), the enter key terminates input and any other key (not already used by the window manager) selects a point.

property number

The figure id, used to identify figures in .pyplot.

pick(mouseevent)[source]

Process a pick event.

Each child artist will fire a pick event if mouseevent is over the artist and the artist has picker set.

See also

Artist.set_picker, Artist.get_picker, Artist.pickable

Return type:

None

savefig(fname, *, transparent=None, **kwargs)[source]

Save the current figure as an image or vector graphic to a file.

Call signature:

savefig(fname, *, transparent=None, dpi='figure', format=None,
        metadata=None, bbox_inches=None, pad_inches=0.1,
        facecolor='auto', edgecolor='auto', backend=None,
        **kwargs
       )

The available output formats depend on the backend being used.

Parameters:
  • fname (str | PathLike | IO) –

    A path, or a Python file-like object, or possibly some backend-dependent object such as matplotlib.backends.backend_pdf.PdfPages.

    If format is set, it determines the output format, and the file is saved as fname. Note that fname is used verbatim, and there is no attempt to make the extension, if any, of fname match format, and no extension is appended.

    If format is not set, then the format is inferred from the extension of fname, if there is one. If format is not set and fname has no extension, then the file is saved with :rc:`savefig.format` and the appropriate extension is appended to fname.

  • transparent (bool | None) –

    If True, the Axes patches will all be transparent; the Figure patch will also be transparent unless facecolor and/or edgecolor are specified via kwargs.

    If False has no effect and the color of the Axes and Figure patches are unchanged (unless the Figure patch is specified via the facecolor and/or edgecolor keyword arguments in which case those colors are used).

    The transparency of these patches will be restored to their original values upon exit of this function.

    This is useful, for example, for displaying a plot on top of a colored background on a web page.

  • dpi (float or ‘figure’, default: :rc:`savefig.dpi`) – The resolution in dots per inch. If ‘figure’, use the figure’s dpi value.

  • format (str) – The file format, e.g. ‘png’, ‘pdf’, ‘svg’, … The behavior when this is unset is documented under fname.

  • metadata (dict, optional) –

    Key/value pairs to store in the image metadata. The supported keys and defaults depend on the image format and backend:

    • ’png’ with Agg backend: See the parameter metadata of ~.FigureCanvasAgg.print_png.

    • ’pdf’ with pdf backend: See the parameter metadata of ~.backend_pdf.PdfPages.

    • ’svg’ with svg backend: See the parameter metadata of ~.FigureCanvasSVG.print_svg.

    • ’eps’ and ‘ps’ with PS backend: Only ‘Creator’ is supported.

    Not supported for ‘pgf’, ‘raw’, and ‘rgba’ as those formats do not support embedding metadata. Does not currently support ‘jpg’, ‘tiff’, or ‘webp’, but may include embedding EXIF metadata in the future.

  • bbox_inches (str or .Bbox, default: :rc:`savefig.bbox`) – Bounding box in inches: only the given portion of the figure is saved. If ‘tight’, try to figure out the tight bbox of the figure.

  • pad_inches (float or ‘layout’, default: :rc:`savefig.pad_inches`) – Amount of padding in inches around the figure when bbox_inches is ‘tight’. If ‘layout’ use the padding from the constrained or compressed layout engine; ignored if one of those engines is not in use.

  • facecolor (:mpltype:`color` or ‘auto’, default: :rc:`savefig.facecolor`) – The facecolor of the figure. If ‘auto’, use the current figure facecolor.

  • edgecolor (:mpltype:`color` or ‘auto’, default: :rc:`savefig.edgecolor`) – The edgecolor of the figure. If ‘auto’, use the current figure edgecolor.

  • backend (str, optional) – Use a non-default backend to render the file, e.g. to render a png file with the “cairo” backend rather than the default “agg”, or a pdf file with the “pgf” backend rather than the default “pdf”. Note that the default backend is normally sufficient. See the-builtin-backends for a list of valid backends for each file format. Custom backends can be referenced as “module://…”.

  • orientation ({'landscape', 'portrait'}) – Currently only supported by the postscript backend.

  • papertype (str) – One of ‘letter’, ‘legal’, ‘executive’, ‘ledger’, ‘a0’ through ‘a10’, ‘b0’ through ‘b10’. Only supported for postscript output.

  • bbox_extra_artists (list of ~matplotlib.artist.Artist, optional) – A list of extra artists that will be considered when the tight bbox is calculated.

  • pil_kwargs (dict, optional) – Additional keyword arguments that are passed to PIL.Image.Image.save when saving the figure.

Return type:

None

set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, canvas=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, constrained_layout=<UNSET>, constrained_layout_pads=<UNSET>, dpi=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, figheight=<UNSET>, figwidth=<UNSET>, frameon=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, layout_engine=<UNSET>, linewidth=<UNSET>, mouseover=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, size_inches=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, tight_layout=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)

Set multiple properties at once.

a.set(a=A, b=B, c=C)

is equivalent to

a.set_a(A)
a.set_b(B)
a.set_c(C)

In addition to the full property names, aliases are also supported, e.g. set(lw=2) is equivalent to set(linewidth=2), but it is an error to pass both simultaneously.

The order of the individual setter calls matches the order of parameters in set(). However, most properties do not depend on each other so that order is rarely relevant.

Supported properties are

Properties:

agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image alpha: float or None animated: bool canvas: FigureCanvas clip_box: ~matplotlib.transforms.BboxBase or None clip_on: bool clip_path: Patch or (Path, Transform) or None constrained_layout: unknown constrained_layout_pads: unknown dpi: float edgecolor: :mpltype:`color` facecolor: :mpltype:`color` figheight: float figure: unknown figwidth: float frameon: bool gid: str in_layout: bool label: object layout_engine: {‘constrained’, ‘compressed’, ‘tight’, ‘none’, .LayoutEngine, None} linewidth: number mouseover: bool path_effects: list of .AbstractPathEffect picker: None or bool or float or callable rasterized: bool size_inches: (float, float) or float sketch_params: (scale: float, length: float, randomness: float) snap: bool or None tight_layout: unknown transform: ~matplotlib.transforms.Transform url: str visible: bool zorder: float

set_canvas(canvas)[source]

Set the canvas that contains the figure

Parameters:

canvas (FigureCanvasBase)

Return type:

None

set_constrained_layout(constrained)[source]

[Deprecated] Set whether constrained_layout is used upon drawing.

If None, :rc:`figure.constrained_layout.use` value will be used.

When providing a dict containing the keys w_pad, h_pad the default constrained_layout paddings will be overridden. These pads are in inches and default to 3.0/72.0. w_pad is the width padding and h_pad is the height padding.

Parameters:

constrained (bool or dict or None)

Notes

Deprecated since version 3.6: Use set_layout_engine(‘constrained’) instead.

set_constrained_layout_pads(**kwargs)[source]

[Deprecated] Set padding for constrained_layout.

Tip: The parameters can be passed from a dictionary by using fig.set_constrained_layout(**pad_dict).

See constrainedlayout_guide.

Parameters:

Notes

Deprecated since version 3.6: Use figure.get_layout_engine().set() instead.

set_dpi(val)[source]

Set the resolution of the figure in dots-per-inch.

Parameters:

val (float)

Return type:

None

set_figheight(val, forward=True)[source]

Set the height of the figure in inches.

Parameters:
  • val (float)

  • forward (bool) – See set_size_inches.

See also

matplotlib.figure.Figure.set_figwidth, matplotlib.figure.Figure.set_size_inches

Return type:

None

set_figwidth(val, forward=True)[source]

Set the width of the figure in inches.

Parameters:
  • val (float)

  • forward (bool) – See set_size_inches.

See also

matplotlib.figure.Figure.set_figheight, matplotlib.figure.Figure.set_size_inches

Return type:

None

set_layout_engine(layout=None, **kwargs)[source]

Set the layout engine for this figure.

Parameters:
  • layout (Literal['constrained', 'compressed', 'tight', 'none'] | LayoutEngine | None) –

    • ‘constrained’ will use ~.ConstrainedLayoutEngine

    • ’compressed’ will also use ~.ConstrainedLayoutEngine, but with a correction that attempts to make a good layout for fixed-aspect ratio Axes.

    • ’tight’ uses ~.TightLayoutEngine

    • ’none’ removes layout engine.

    If a .LayoutEngine instance, that instance will be used.

    If None, the behavior is controlled by :rc:`figure.autolayout` (which if True behaves as if ‘tight’ was passed) and :rc:`figure.constrained_layout.use` (which if True behaves as if ‘constrained’ was passed). If both are True, :rc:`figure.autolayout` takes priority.

    Users and libraries can define their own layout engines and pass the instance directly as well.

  • **kwargs – The keyword arguments are passed to the layout engine to set things like padding and margin sizes. Only used if layout is a string.

Return type:

None

set_size_inches(w, h=None, forward=True)[source]

Set the figure size in inches.

Call signatures:

fig.set_size_inches(w, h)  # OR
fig.set_size_inches((w, h))
Parameters:
  • w (float | tuple[float, float]) – Width and height in inches (if height not specified as a separate argument) or width.

  • h (float | None) – Height in inches.

  • forward (bool) – If True, the canvas size is automatically updated, e.g., you can resize the figure window from the shell.

See also

matplotlib.figure.Figure.get_size_inches, matplotlib.figure.Figure.set_figwidth, matplotlib.figure.Figure.set_figheight

Return type:

None

Notes

To transform from pixels to inches divide by Figure.dpi.

set_tight_layout(tight)[source]

[Deprecated] Set whether and how .Figure.tight_layout is called when drawing.

Parameters:

tight (bool or dict with keys "pad", "w_pad", "h_pad", "rect" or None) – If a bool, sets whether to call .Figure.tight_layout upon drawing. If None, use :rc:`figure.autolayout` instead. If a dict, pass it as kwargs to .Figure.tight_layout, overriding the default paddings.

Notes

Deprecated since version 3.6: Use set_layout_engine instead.

show(warn=True)[source]

If using a GUI backend with pyplot, display the figure window.

If the figure was not created using ~.pyplot.figure, it will lack a ~.backend_bases.FigureManagerBase, and this method will raise an AttributeError.

Warning

This does not manage a GUI event loop. Consequently, the figure may only be shown briefly or not shown at all if you or your environment are not managing an event loop.

Use cases for .Figure.show include running this from a GUI application (where there is persistently an event loop running) or from a shell, like IPython, that install an input hook to allow the interactive shell to accept input while the figure is also being shown and interactive. Some, but not all, GUI toolkits will register an input hook on import. See cp_integration for more details.

If you’re in a shell without input hook integration or executing a python script, you should use matplotlib.pyplot.show with block=True instead, which takes care of starting and running the event loop for you.

Parameters:

warn (bool) – If True and we are not running headless (i.e. on Linux with an unset DISPLAY), issue warning when called on a non-GUI backend.

Return type:

None

tight_layout(*, pad=1.08, h_pad=None, w_pad=None, rect=None)[source]

Adjust the padding between and around subplots.

To exclude an artist on the Axes from the bounding box calculation that determines the subplot parameters (i.e. legend, or annotation), set a.set_in_layout(False) for that artist.

Parameters:
  • pad (float) – Padding between the figure edge and the edges of subplots, as a fraction of the font size.

  • h_pad (float | None) – Padding (height/width) between edges of adjacent subplots, as a fraction of the font size.

  • w_pad (float | None) – Padding (height/width) between edges of adjacent subplots, as a fraction of the font size.

  • rect (tuple[float, float, float, float] | None) – A rectangle in normalized figure coordinates into which the whole subplots area (including labels) will fit.

See also

Figure.set_layout_engine, pyplot.tight_layout

Return type:

None

waitforbuttonpress(timeout=-1)[source]

Blocking call to interact with the figure.

Wait for user input and return True if a key was pressed, False if a mouse button was pressed and None if no input was given within timeout seconds. Negative values deactivate timeout.

Return type:

None | bool

pyPenred.plotResults(simObj, tallyName: str, prefix: str = '', titles: list = [], fontSize: int = 20, labelPad: int = 20, width: int = 12, height: int = 9, markerSize: int = 6, capSize: int = 5, aspect: str = 'auto', vrange: list = [], erange: list = [], grid: bool = False, show: bool = False)[source]

Read and plot the results from a simulation object with a finished simulation. This function requires the matplotlib module, which will be installed in the system if it is not.

Parameters:
pyPenred.readConfigFile(filename)[source]

Read a configuration file in both, YAML or penRed internal format, and returns the associated dictionary.

pyPenred.runFromFile(configFile='config.in', statusTime=20, configLog='config.log', simulationLog='simulation.log')[source]

Configures and runs a simulation from the specified file. Reports the simulation status periodically.

pyPenred.writeConfigFile(filename, d)[source]

Write a configuration file in penRed internal format, from the data stored in the dictionary.