xyzpy.plot.plotter_matplotlib
xyzpy.plot.plotter_matplotlib#
Functions for plotting datasets nicely.
Functions
|
|
|
Auto version of |
|
Auto version of |
|
Auto version of |
|
Auto version of |
|
|
|
Simple wrapper to handle sequence of arrays as input to e.g. |
|
From |
|
Dataset histogram. |
|
From |
|
Decorate a plotting function to plot a grid of values. |
|
From |
|
|
|
|
|
|
|
Visualize all entries of a tensor, with indices mapped into the plane and values mapped into a color wheel. |
Classes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- class xyzpy.plot.plotter_matplotlib.LinePlot(ds, x, y, z=None, *, y_err=None, x_err=None, **kwargs)[source]#
- class xyzpy.plot.plotter_matplotlib.PlotterMatplotlib(ds, x, y, z=None, y_err=None, x_err=None, **kwargs)[source]#
- xyzpy.plot.plotter_matplotlib.auto_heatmap(x, **heatmap_opts)[source]#
Auto version of
heatmap()
that accepts array arguments by converting them to aDataset
first.
- xyzpy.plot.plotter_matplotlib.auto_histogram(x, **histogram_opts)[source]#
Auto version of
histogram()
that accepts array arguments by converting them to aDataset
first.
- xyzpy.plot.plotter_matplotlib.auto_lineplot(x, y_z, **lineplot_opts)[source]#
Auto version of
lineplot()
that accepts array arguments by converting them to aDataset
first.
- xyzpy.plot.plotter_matplotlib.auto_scatter(x, y_z, **scatter_opts)[source]#
Auto version of
scatter()
that accepts array arguments by converting them to aDataset
first.
- xyzpy.plot.plotter_matplotlib.handle_sequence_of_arrays(vis_fn)[source]#
Simple wrapper to handle sequence of arrays as input to e.g.
visualize_tensor
.
- xyzpy.plot.plotter_matplotlib.heatmap(ds, x, y, z, **kwargs)[source]#
From
ds
plot variablez
as a function ofx
andy
using a 2D heatmap.- Parameters
ds (xarray.Dataset) – Dataset to plot from.
x (str) – Dimension to plot along the x-axis.
y (str) – Dimension to plot along the y-axis.
z (str, optional) – Variable to plot as colormap.
row (str, optional) – Dimension to vary over as a function of rows.
col (str, optional) – Dimension to vary over as a function of columns.
plot_opts – See
xyzpy.plot.core.PLOTTER_DEFAULTS
.
- xyzpy.plot.plotter_matplotlib.histogram(ds, x, z=None, **plot_opts)[source]#
Dataset histogram.
- Parameters
ds (xarray.Dataset) – The dataset to plot.
x (str, sequence of str) – The variable(s) to plot the probability density of. If sequence, plot a histogram of each instead of using a
z
coordinate.z (str, optional) – If given, range over this coordinate a plot a histogram for each.
row (str, optional) – Dimension to vary over as a function of rows.
col (str, optional) – Dimension to vary over as a function of columns.
plot_opts – See
xyzpy.plot.core.PLOTTER_DEFAULTS
.
- xyzpy.plot.plotter_matplotlib.lineplot(ds, x, y, z=None, y_err=None, x_err=None, **plot_opts)[source]#
From
ds
plot lines ofy
as a function ofx
, optionally for varyingz
.- Parameters
ds (xarray.Dataset) – Dataset to plot from.
x (str) – Dimension to plot along the x-axis.
y (str or tuple[str]) – Variable(s) to plot along the y-axis. If tuple, plot each of the variables - instead of
z
.z (str, optional) – Dimension to plot into the page.
y_err (str, optional) – Variable to plot as y-error.
x_err (str, optional) – Variable to plot as x-error.
row (str, optional) – Dimension to vary over as a function of rows.
col (str, optional) – Dimension to vary over as a function of columns.
plot_opts – See
xyzpy.plot.core.PLOTTER_DEFAULTS
.
- xyzpy.plot.plotter_matplotlib.mpl_multi_plot(fn)[source]#
Decorate a plotting function to plot a grid of values.
- xyzpy.plot.plotter_matplotlib.scatter(ds, x, y, z=None, y_err=None, x_err=None, **plot_opts)[source]#
From
ds
plot a scatter ofy
againstx
, optionally for varyingz
.- Parameters
ds (xarray.Dataset) – Dataset to plot from.
x (str) – Quantity to plot along the x-axis.
y (str or tuple[str]) – Quantity(s) to plot along the y-axis. If tuple, plot each of the variables - instead of
z
.z (str, optional) – Dimension to plot into the page.
y_err (str, optional) – Variable to plot as y-error.
x_err (str, optional) – Variable to plot as x-error.
row (str, optional) – Dimension to vary over as a function of rows.
col (str, optional) – Dimension to vary over as a function of columns.
plot_opts – See
xyzpy.plot.core.PLOTTER_DEFAULTS
.
- xyzpy.plot.plotter_matplotlib.visualize_tensor(array, max_projections=None, angles=None, scales=None, projection_overlap_spacing=1.05, skew_factor=0.05, spacing_factor=1.0, magscale='linear', size_map=True, size_pow=0.5, size_scale=1.0, alpha_map=True, alpha_pow=0.5, alpha=0.8, marker='o', linewidths=0, show_lattice=True, lattice_opts=None, compass=False, compass_loc='auto', compass_size=0.1, compass_bounds=None, compass_labels=None, compass_opts=None, max_mag=None, legend=False, legend_loc='auto', legend_size=0.15, legend_bounds=None, legend_resolution=3, interleave_projections=False, reverse_projections=False, facecolor=None, rasterize=4096, rasterize_dpi=300, figsize=(5, 5), ax=None)[source]#
Visualize all entries of a tensor, with indices mapped into the plane and values mapped into a color wheel.
- Parameters
array (ndarray) – The tensor to visualize.
skew_factor (float, optional) – When there are more than two dimensions, a factor to scale the rotations by to avoid overlapping data points.
size_map (bool, optional) – Whether to map the tensor value magnitudes to marker size.
size_scale (float, optional) – An overall factor to scale the marker size by.
alpha_map (bool, optional) – Whether to map the tensor value magnitudes to marker alpha.
alpha_pow (float, optional) – The power to raise the magnitude to when mapping to alpha.
alpha (float, optional) – The overall alpha to use for all markers if
not alpha_map
.show_lattice (bool, optional) – Show a small grey dot for every ‘lattice’ point regardless of value.
lattice_opts (dict, optional) – Options to pass to
maplotlib.Axis.scatter
for the lattice points.linewidths (float, optional) – The linewidth to use for the markers.
marker (str, optional) – The marker to use for the markers.
figsize (tuple, optional) – The size of the figure to create, if
ax
is not provided.ax (matplotlib.Axis, optional) – The axis to draw to. If not provided, a new figure will be created.
- Returns
fig (matplotlib.Figure) – The figure containing the plot, or
None
ifax
was provided.ax (matplotlib.Axis) – The axis containing the plot.