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.
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

fig

im

property array
array for plot. Internally, stored at self.data[‘array’]
property ax
the axes containing this image
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.