XarrayImagePlotElement
- class PlasmaCalcs.plotting.images.XarrayImagePlotElement(array, *, ax=None, x=None, y=None, image_mode='pcolormesh', add_colorbar=UNSET, add_labels=True, **kw_super)
Bases:
MoviePlotElementimage 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 Axesthe attached mpl.axes.Axes object.None –> will use self.ax=plt.gca() when getting self.ax for the first time.x, y: None or strif provided, tells coords for x and y axes. Passed directly to array.plot.pcolormesh or .imshow.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).Methods
__init_subclass__(*args_super, **kw)appends note about using self.plot_settings, to cls.__doc__.
init_im()initialize image on self.ax; actually plot the data.
plots xlabel and ylabel from self.plot_settings.
update_data(data)update the plot using data['array'].
Attributes
array for plot.
the axes containing this image
Colorbar object associated with this image.
figure containing this image
the image object (instance of matplotlib.cm.ScalarMappable)
- classmethod __init_subclass__(*args_super, **kw)
appends note about using self.plot_settings, to cls.__doc__.
if “PlotSettings” or “plot_settings” appears in cls.__doc__, do NOT append this note;assuming instead that this means the doc already mentions how to use plot_settings.
- 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.