scistag.plotstag.plot.Plot¶
- class Plot(target_size=None)[source]¶
Bases:
objectDefines a single plot.
A plot defines an area within a
Figurewhich can consist of one or multiple plots overlaying of each other using the :class:`PlotLayer`s provided such as line charts, scatter plots, images etc.- Parameters
target_size (Size2DTypes | None) – The target size in pixels
Methods
Adds an image layer
Adds a layer to this plot
Adds a matplotlib figure as image layer to the plot
Returns the plot's figure.
Paints the plot and all of it's layers and subcomponents such as the legend.
Renders the plot's figure
Links the plot to the figure which contains it
Sets the plot's title
Updates the plot's layout to compute the plot's efficient size
Updates the current layer offset :return:
Attributes
__dict____doc____module____weakref__list of weak references to the object (if defined)
Desired target size in pixels
Plot's effective size in pixels (as far as defined)
Single data visualization layers (the real plots)
Border width in pixels
Border margin in pixels
Border color
Margin around the main layers in pixels on each side (left, top, right, bottom)
Position at which the layers shall be plotted
The layer size in pixels
Figure which contains this plot
Column in which the plot is displayed.
Row in which the plot is displayed.
Enumeration index of the plot.
The plot's title
The title's size in pixels
Cached title font
Space above and below the title
The title's color
- _paint_decoration(canvas)[source]¶
Paints the decoration such as border and title
- Parameters
canvas – The target canvas
- add_image(image, size_ratio=None, bg_fill='cb')[source]¶
Adds an image layer
- Parameters
image (Image | np.ndarray) – The image to plot
size_ratio (float | tuple[float, float] | None) –
The size ratio from the image’s or matrix original size to effective pixels. This can be used to plot images in original size rather than being auto-scaled through the plot’s configuration.
1.0 = keep the original size.
0.5 = 50% of the original size
…
bg_fill (str | Color | None) –
Defines the background which shall be used if the image is alpha-transparent. If a color is passed the whole background will be filled with given color.
”cb” (checkerboard) by default.
- Return type
- add_matplot(figure=None, size_ratio=None, **params)[source]¶
Adds a matplotlib figure as image layer to the plot
- Parameters
figure (plt.Figure | None) – The figure to be added
size_ratio (float | None) – If set the plot will be scaled with given factor
params – The parameters to be passed to the figure if a new figure shall be created.
- Returns
The Plot if a figure was passed (and so no further action is required).
Otherwise an MPLayerLock which shall be used the following way:
with my_plot.add_matplot() as plt: plt.title(...) plt.imshow(...)
- get_figure()[source]¶
Returns the plot’s figure.
If no figure was assigned yet it will automatically create it
- Returns
The figure
- paint(canvas)[source]¶
Paints the plot and all of it’s layers and subcomponents such as the legend.
- Parameters
canvas (
Canvas) – The target canvas
- render()[source]¶
Renders the plot’s figure
- Return type
- Returns
The visualization of the plot as
Image
- _figure: Optional['Figure']¶
Figure which contains this plot
- border_color¶
Border color
- border_margins¶
Border margin in pixels
- border_width¶
Border width in pixels
- column¶
Column in which the plot is displayed. Auto-assigned by the figure
- index¶
Enumeration index of the plot. Auto-assigned by the figure
- layer_pos¶
Position at which the layers shall be plotted
- layer_size¶
The layer size in pixels
- margins¶
Margin around the main layers in pixels on each side (left, top, right, bottom)
- row¶
Row in which the plot is displayed. Auto-assigned by the figure
- target_size¶
Desired target size in pixels
- title¶
The plot’s title
- title_color¶
The title’s color
- title_height¶
The title’s size in pixels