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.GridDatasetusing anata.plots.types.LinePlotornata.plots.types.ColorPlotif 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 onaxesif it is a child axes offig, otherwise a new axes is created onfig. Iffigis not provided, a newnata.plots.Figureis created.axes (
nata.plots.Axes, optional) – If provided, the plot is drawn onaxes, which must be an axes offig. Ifaxesis not provided or is provided without a correspondingfig, a newnata.plots.Axesis created in a newnata.plots.Figure.style (
dict, optional) – Dictionary that takes a mix of style properties ofnata.plots.Figure,nata.plots.Axesand any plot type (seenata.plots.types.LinePlotornata.plots.types.ColorPlot).interactive (
bool, optional) – Controls wether interactive widgets should be shown with the plot to allow for temporal navigation. Only applicable ifdatasethas multiple iterations.n (
int, optional) – Selects the index of the iteration to be shown initially. Only applicable ifdatasethas multiple iterations, .
- Returns
nata.plots.FigureorNone– Figure with plot built based ondataset. Interactive widgets are shown with the figure ifdatasethas 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.Figureis 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. Ifaxesis 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])