plopp.backends.matplotlib.canvas.Canvas#
- class plopp.backends.matplotlib.canvas.Canvas(ax=None, cax=None, figsize=None, title=None, grid=False, vmin=None, vmax=None, autoscale='auto', aspect='auto', cbar=False, legend=True, **ignored)[source]#
Matplotlib-based canvas used to render 2D graphics. It provides a figure and some axes, as well as functions for controlling the zoom, panning, and the scale of the axes.
- Parameters:
ax (
Optional
[Axes
], default:None
) – If supplied, use these axes to create the figure. If none are supplied, the canvas will create its own axes.cax (
Optional
[Axes
], default:None
) – If supplied, use these axes for the colorbar. If none are supplied, and a colorbar is required, the canvas will create its own axes.figsize (
Optional
[Tuple
[float
,float
]], default:None
) – The width and height of the figure, in inches.title (
Optional
[str
], default:None
) – The title to be placed above the figure.grid (
bool
, default:False
) – Display the figure grid ifTrue
.vmin (
Union
[Variable
,int
,float
,None
], default:None
) – The minimum value for the vertical axis. If a number (without a unit) is supplied, it is assumed that the unit is the same as the current vertical axis unit.vmax (
Union
[Variable
,int
,float
,None
], default:None
) – The maximum value for the vertical axis. If a number (without a unit) is supplied, it is assumed that the unit is the same as the current vertical axis unit.autoscale (
Literal
['auto'
,'grow'
], default:'auto'
) – The behavior of the axis limits. Ifauto
, the limits automatically adjusts every time the data changes. Ifgrow
, the limits are allowed to grow with time but they do not shrink.aspect (
Literal
['auto'
,'equal'
], default:'auto'
) – The aspect ratio for the axes.cbar (
bool
, default:False
) – Add axes to host a colorbar ifTrue
.legend (
Union
[bool
,Tuple
[float
,float
]], default:True
) – Show legend ifTrue
. Iflegend
is a tuple, it should contain the(x, y)
coordinates of the legend’s anchor point in axes coordinates.
- __init__(ax=None, cax=None, figsize=None, title=None, grid=False, vmin=None, vmax=None, autoscale='auto', aspect='auto', cbar=False, legend=True, **ignored)[source]#
Methods
__init__
([ax, cax, figsize, title, grid, ...])autoscale
()Find the limits of the artists on the canvas and adjust the axes ranges.
download_figure
()Save the figure to a PNG file via a pop-up dialog.
draw
()Make a draw call to the underlying figure.
finalize
()Finalize is called at the end of figure creation.
format_coord
(x, y)Format the coordinates of the mouse pointer to show the value of the data at that point.
is_widget
()logx
()Toggle the scale between
linear
andlog
along the horizontal axis.logy
()Toggle the scale between
linear
andlog
along the vertical axis.pan
()Activate the underlying Matplotlib pan tool.
panzoom
(value)Activate or deactivate the pan or zoom tool, depending on the input value.
register_format_coord
(formatter)Register a custom axis formatter for the x-axis.
reset_mode
()Reset the Matplotlib toolbar mode to nothing, to disable all Zoom/Pan tools.
save
(filename, **kwargs)Save the figure to file.
set_axes
(dims, units, dtypes)Set the axes dimensions and units.
show
()Make a call to Matplotlib's underlying
show
function.to_image
()Convert the underlying Matplotlib figure to an image widget from
ipywidgets
.to_widget
()zoom
()Activate the underlying Matplotlib zoom tool.
Attributes
cblabel
Get or set the label of the colorbar.
empty
Check if the canvas is empty.
grid
Get or set the visibility of the grid.
title
Get or set the title of the plot.
xlabel
Get or set the label of the x-axis.
xmax
Get or set the upper (right) bound of the x-axis.
xmin
Get or set the lower (left) bound of the x-axis.
xrange
Get or set the range/limits of the x-axis.
xscale
Get or set the scale of the x-axis ('linear' or 'log').
ylabel
Get or set the label of the y-axis.
ymax
Get or set the upper (top) bound of the y-axis.
ymin
Get or set the lower (bottom) bound of the y-axis.
yrange
Get or set the range/limits of the y-axis.
yscale
Get or set the scale of the y-axis ('linear' or 'log').