FaceplotPlotElement

class PlasmaCalcs.plotting.faceplot.FaceplotPlotElement(coords, data, *, ax=None, xlabel='x', ylabel='y', zlabel='z', add_colorbar=True, **kw_super)

Bases: MoviePlotElement

3 plots on 3 faces of a box in 3D.

Faceplot.__init__ will make these plots.
Troubleshooting colors? Try providing vmin, vmax, & levels, explicitly!
coords: dictlike with keys ‘x’, ‘y’, ‘z’
1D coordinate arrays along each dimension.
data: dictlike with keys ‘x_y’, ‘x_z’, ‘y_z’
2D arrays of data to plot on the faces.
E.g. ‘x_z’ data will go on the x-z face.
ax: None or axes with 3d projection.
e.g. fig.add_subplot(1,1,1, projection=’3d’)
if None, use plt.gca() if current axes exist, else make new axes.
Additional kwargs control settings for the plot:
faceplot_view_angle: UNSET, None, or 3-tuple of numbers (default: UNSET)
viewing angle for 3D faceplots, as (elevation, azimuth, roll).
UNSET –> use DEFAULTS.PLOT.FACEPLOT_VIEW_ANGLE (default: (-160, 30, 0)).
None –> use matplotlib defaults.
faceplot_edge_kwargs: UNSET, None, or dict (default: UNSET)
kwargs for edge lines in 3D faceplots.
UNSET –> use DEFAULTS.PLOT.FACEPLOT_EDGE_KWARGS (default: {‘color’: ‘0.4’, ‘linewidth’: 1, ‘zorder’: 1000.0}).
None –> don’t plot edge lines.
empty dict –> use matplotlib defaults.
faceplot_axes_zoom: UNSET or number>0 (default: UNSET)
zoom for faceplot axis. matplotlib default is zoom=1.
UNSET –> use DEFAULTS.PLOT.FACEPLOT_AXES_ZOOM (default: 1.0).
aspect3d: UNSET, None, str, 3-tuple of numbers, or 4-tuple of numbers (default: UNSET)
aspect ratio for 3D plots.
UNSET –> use DEFAULTS.PLOT.ASPECT3D (default: equal).
str –> ‘auto’ or ‘equal’
tuple of 3 numbers –> (x aspect, y aspect, z aspect)
tuple of 4 numbers –> (1, x multiplier, y multiplier, z multiplier);
multiplier multiplies aspect determined by data lengths.
any of these kwargs for ax.contourf:
‘vmin’, ‘vmax’, ‘levels’, ‘cmap’,
any of these kwargs for ax.set:
‘xlabel’, ‘ylabel’, ‘zlabel’, ‘xlim’, ‘ylim’, ‘zlim’,
‘xticks’, ‘yticks’, ‘zticks’, ‘xticklabels’, ‘yticklabels’, ‘zticklabels’
Note the defaults for ‘xlabel’, ‘ylabel’, ‘zlabel’ will be ‘x’, ‘y’, ‘z’.
add_colorbar: bool
whether to self.colorbar() during __init__.
colorbar_kw: unset or dict (default: UNSET)
any additional kwargs for plt.colorbar.
These attrs of self will be created/updated during init (here, face=’x_y’, ‘x_z’, or ‘y_z’):

meshgrids: {face: {x: 2d array of x values at face} for x in face} coord_lims: {x: [min, max] for x in ‘x’, ‘y’, ‘z’} data_lims: {‘all’: [min, max], **{face: [min, max]} } ax: the axes object to plot on; create if needed. faces: {face: the mpl_toolkits.mplot3d.art3d.QuadContourSet3D plotted on this face} edges: {x: the mpl_toolkits.mplot3d.art3d.Line3D plotted at x=0. x=’x’, ‘y’ or ‘z’}

To view or adjust plot settings in self, see self.plot_settings, or help(self.plot_settings).

Methods

__getitem__(k)

returns self.faces[k] for 'x_y', 'x_z', or 'y_z', else self.edges[k] for 'x', 'y', or 'z',

__init_subclass__(*args_super, **kw)

appends note about using self.plot_settings, to cls.__doc__.

colorbar(**kw_plt_colorbar)

add a colorbar to the figure.

from_dataset(ds, **kw)

create Faceplot from an xarray.Dataset.

init_all()

call all relevant init_* methods.

init_ax()

initialize ax for self.

init_coord_lims()

initialize self.coord_lims based on self.coords.

init_data_lims()

initialize self.data_lims based on self.data.

init_edges()

initialize the edges on self.ax; actually plot the edges.

init_faces()

initialize the faces on self.ax; actually plot the data.

init_meshgrids()

initialize self.meshgrids based on coords from self.coords.

init_viewing()

initialize view-related things: labels, viewing angle, aspect ratio, etc.

update_data(data)

updates the data on the plot to match the data provided here.

_plot_face(face, data2d)

plots this data (2d array) on this face.

Attributes

fig

figure containing this faceplot.

__getitem__(k)

returns self.faces[k] for ‘x_y’, ‘x_z’, or ‘y_z’, else self.edges[k] for ‘x’, ‘y’, or ‘z’,

else crash with KeyError.
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.
_plot_face(face, data2d)

plots this data (2d array) on this face.

updates self.faces accordingly. removes old face if it exists.
returns the newly plotted face.
colorbar(**kw_plt_colorbar)

add a colorbar to the figure. sets self.cbar = Colorbar object, and returns it.

Troubleshooting colors? Try providing vmin, vmax, & levels, explicitly!
property fig

figure containing this faceplot.

classmethod from_dataset(ds, **kw)

create Faceplot from an xarray.Dataset.

Equivalent: cls(ds.coords, ds, **kw)
init_all()

call all relevant init_* methods.

init_ax()

initialize ax for self. returns self.ax

init_coord_lims()

initialize self.coord_lims based on self.coords.

self.coord_lims = {x: [min, max] for x in ‘x’, ‘y’, ‘z’}
returns self.coord_lims.
init_data_lims()

initialize self.data_lims based on self.data.

data_lims = {
‘x_y’: [min, max] of data[‘x_y’],
‘x_z’: [min, max] of data[‘x_z’],
‘y_z’: [min, max] of data[‘y_z’],
‘all’: [min, max] of all data,
}
returns self.data_lims.
init_edges()

initialize the edges on self.ax; actually plot the edges.

stores plotted objects in self.edges & returns self.edges.
edges will not be plotted if self.plot_settings.get(‘faceplot_edge_kwargs’) is None.
init_faces()

initialize the faces on self.ax; actually plot the data.

stores plotted objects in self.faces & returns self.faces.
init_meshgrids()

initialize self.meshgrids based on coords from self.coords.

self.meshgrids = {
‘x_y’: {‘x’: 2d array of x coords in x_y plot,
‘y’: 2d array of y coords in x_y plot},
‘x_z’: {‘x’: 2d array of x coords in x_z plot,
‘z’: 2d array of z coords in x_z plot},
‘y_z’: {‘y’: 2d array of y coords in y_z plot,
‘z’: 2d array of z coords in y_z plot},
}
returns self.meshgrids.
init_viewing()

initialize view-related things: labels, viewing angle, aspect ratio, etc.

update_data(data)

updates the data on the plot to match the data provided here.

data: dictlike with keys ‘x_y’, ‘x_z’, ‘y_z’
2D arrays of data to plot on the faces.
E.g. ‘x_z’ data will go on the x-z face.
returns the list of updated face artist objects.