Plot¶
-
nata.containers.GridDataset.
plot
(dataset: nata.containers.GridDataset, fig: Optional[nata.plots.figure.Figure] = None, axes: Optional[nata.plots.axes.Axes] = None, style: Optional[dict] = {}, interactive: Optional[bool] = True, n: Optional[int] = 0) → Optional[nata.plots.figure.Figure]¶ Plots a single/multiple iteration
nata.containers.GridDataset
using anata.plots.types.LinePlot
ornata.plots.types.ColorPlot
if the dataset is one- or two-dimensional, respectively.- Parameters
fig (
nata.plots.Figure
, optional) – If provided, the plot is drawn onfig
. The plot is drawn onaxes
if it is a child axes offig
, otherwise a new axes is created onfig
. Iffig
is not provided, a newnata.plots.Figure
is created.axes (
nata.plots.Axes
, optional) – If provided, the plot is drawn onaxes
, which must be an axes offig
. Ifaxes
is not provided or is provided without a correspondingfig
, a newnata.plots.Axes
is created in a newnata.plots.Figure
.style (
dict
, optional) – Dictionary that takes a mix of style properties ofnata.plots.Figure
,nata.plots.Axes
and any plot type (seenata.plots.types.LinePlot
ornata.plots.types.ColorPlot
).interactive (
bool
, optional) – Controls wether interactive widgets should be shown with the plot to allow for temporal navigation. Only applicable ifdataset
has multiple iterations.n (
int
, optional) – Selects the index of the iteration to be shown initially. Only applicable ifdataset
has multiple iterations, .
- Returns
nata.plots.Figure
orNone
– Figure with plot built based ondataset
. Interactive widgets are shown with the figure ifdataset
has multiple iterations, in which case this method returnsNone
.
Examples
To get a plot with default style properties in a new figure, simply call the
.plot()
method of the dataset.>>> from nata.containers import GridDataset >>> import numpy as np >>> arr = np.arange(10) >>> ds = GridDataset.from_array(arr) >>> fig = ds.plot()
In case a
nata.plots.Figure
is returned by the method, it can be shown by calling thenata.plots.Figure.show()
method.>>> fig.show()
To draw a new plot on
fig
, we can pass it as an argument to the.plot()
method. Ifaxes
is provided, the new plot is drawn on the selected axes.>>> ds2 = GridDataset.from_array(arr**2) >>> fig = ds2.plot(fig=fig, axes=fig.axes[0])