PlasmaCalcs.plotting.images.XarrayImagePlotElement

class PlasmaCalcs.plotting.images.XarrayImagePlotElement(array, *, ax=None, image_mode='pcolormesh', add_colorbar=UNSET, add_labels=True, **kw_super)

Bases: ImagePlotElement

image on an Axes, for an xarray.DataArray.
“image” refers to a matplotlib.cm.ScalarMappable object, e.g. the result of imshow or pcolormesh.
array: xarray.DataArray, probably ndim=2.
the data to be plotted.
ax: None or Axes
the attached mpl.axes.Axes object.
None –> will use self.ax=plt.gca() when getting self.ax for the first time.
image_mode: str (‘imshow’ or ‘pcolormesh’) (default: pcolormesh)
tells whether this image will be pcolormesh or imshow.
add_colorbar: UNSET or bool (default: UNSET)
if provided, default for add_colorbar when making xarray plots.
add_labels: bool (default: True)
whether to add labels to xarray plots.
min_n_ticks: UNSET, None, int, or 2-tuple of ints (default: UNSET)
minimum number of ticks to use on plot axes, e.g. x & y axes.
UNSET –> use DEFAULTS.PLOT.MIN_N_TICKS (default: 3).
None –> use matplotlib default (probably 2).
int –> use this number of ticks.
tuple –> provides (min for x, min for y).
min_n_ticks_cbar: UNSET, None, int, or 2-tuple of ints (default: UNSET)
minimum number of ticks to use on colorbars.
UNSET –> use DEFAULTS.PLOT.MIN_N_TICKS_CBAR (default: 3).
None –> use matplotlib default (probably 2).
int –> use this number of ticks.
tuple –> provides (min for horizontal cbars, min for vertical cbars).
grid: UNSET, bool, or dict (default: UNSET)
whether to ax.grid() for each axes.
UNSET –> use rcParams[“axes.grid”].
True –> ax.grid(True) for all axes.
False –> ax.grid(False) for all axes.
dict –> ax.grid(**grid) for all axes.
To view or adjust plot settings in self, see self.plot_settings, or help(self.plot_settings).
__init__(array, *, ax=None, image_mode='pcolormesh', add_colorbar=UNSET, add_labels=True, **kw_super)

Methods

__init__(array, *[, ax, image_mode, ...])

init_im()

plot_labels()

update_data(data)

Attributes

array

ax

cbar

fig

im

property array
array for plot. Internally, stored at self.data[‘array’]
property ax
the axes containing this image
property cbar
Colorbar object associated with this image. False if no associated colorbar.
None if self.im does not exist yet (i.e. not yet plotted).
“associated” meaning: colorbar using this image as its scalar mappable.
property fig
figure containing this image
property im
the image object (instance of matplotlib.cm.ScalarMappable)
init_im()
initialize image on self.ax; actually plot the data.
stores plotted object in self.im & returns self.im.
plot_labels()
plots xlabel and ylabel from self.plot_settings.
If xlabel or ylabel not provided:
- use defaults from xarray’s plot method.
- if array.attrs has ‘coords_units’, put that in brackets, e.g. ‘x [si]’.
If they are provided, use them, but also .format(**array.attrs).
(e.g. ‘x [{units}]’ becomes ‘x [si]’ if array.attrs[‘units’] == ‘si’)
update_data(data)
update the plot using data[‘array’].
return list of all updated matplotlib Artist objects.