scistag.plotstag.figure.Figure¶
- class Figure(cols=1, rows=1, dims=None, size=None, count=None, plot_size=None, scaling=1.0, stepping='rightDown', borderless=False)¶
Bases:
objectDefines a canvas onto which one or multiple :class:`Plot`s may be printed, manages their appearance, their behavior and different methods to rasterize or export plots.
- Parameters
rows (int) – The number of rows
cols (int | None) – The number of columns
dims (tuple[int | None, int | None] | None) –
The count of columns and rows as tuple. Overwrites rows and columns if provided.
Examples:
size (Size2DTypes | None) –
The (precise) target size in pixels.
Great for plotting diagrams etc. with precise size, not well suited for images and matrices. Prefer plot_default_size for such data types.
count (int | None) – If specified it will automatically adjust the row count to be able to store all elements. If columns is explicitly set to None it will adjust the column count instead.
plot_size (tuple[float, float] | None) – The area provided per plot if no other size is enforced. Adapts better to the size of images and matrices.
scaling (float) – The figure’s DPI based scaling factor (1.0 = 96 DPI)
stepping (GridSteppingMode | str) –
Defines the mode and order in which the cursor iterates through the figure when using
for plot in figure. SeeGridSteppingModeAlso allows short-codes such as “rightDown”, “rd” or “downRight” as defined in
GridSteppingMode.borderless (bool) – If set to true by default all borders and margins will be removed for the figure and all plots.
Methods
Adds a matplotlib layer and provides access to the matplot functions
Adds an empty plot at given location.
Removes all borders from the figure and (if set so) by default from all sub plots.
Returns the location of given grid by enumeration index.
Renders the figure and returns it as image
Updates a plot ot a specific index.
Changes the behavior in which order the single grids of this figure are iterated and indexed.
Sets the plot's title
Updates the layouting of all plots and the own size
Updates the figure's margins
Attributes
__dict____doc____module____weakref__list of weak references to the object (if defined)
- _determine_col_row_sizes()¶
Determines the efficient size of all plots :rtype:
tuple[list[float],list[float]] :return: The width of the single columns and the height of the singlerows.
- _get_target_plot_size()¶
Returns the target size of the defined plot (if a target size was defined).
- Return type
Size2D | None
- Returns
The size in pixels
- _render_plots(canvas)¶
Renders the single plots
- Parameters
canvas – The target canvas
- _render_single_plot(canvas, cur_col, cur_row, x_off, y_off)¶
Renders a single plot
- Parameters
canvas – The tagret canvsa
cur_col – The current column
cur_row – The current row
x_off – The x offset
y_off – The y offset
- _update_blocked_space()¶
Updates the blocked space computation to determine how much space is available for the plots
- add_matplot(col=0, row=0, size_ratio=1.0, **params)¶
Adds a matplotlib layer and provides access to the matplot functions
Usage:
- Parameters
- Return type
- Returns
The lock handle
- add_plot(col=0, row=0)¶
Adds an empty plot at given location.
If a plot was already assigned the existing plot will be returned.
- borderless(mode='all')¶
Removes all borders from the figure and (if set so) by default from all sub plots.
- get_location(enum_index)¶
Returns the location of given grid by enumeration index.
Note: In which order the grids are processed is defined by
iteration_steppingso index 0 is not necessarily 0, 0 but e.g. in a stepping from the upper left corner could also start at 0, row_count-1.
- render()¶
Renders the figure and returns it as image
- Return type
- Returns
The visualization of the plot as
Image
- set_plot(plot, column=0, row=0)¶
Updates a plot ot a specific index.
If not index is specified it will define the main plot (0,0).
- set_stepping_mode(mode)¶
Changes the behavior in which order the single grids of this figure are iterated and indexed. By default the cursor moves from left ro right and then continues in the next row.
With other modes you can for example fill the grid in a different order, e.g. from to to bottom, see
GridSteppingMode.- Parameters
mode (
GridSteppingMode) – The new mode
- set_title(title)¶
Sets the plot’s title
- update_layouts()¶
Updates the layouting of all plots and the own size
- update_margins()¶
Updates the figure’s margins