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 a nata.plots.types.LinePlot or nata.plots.types.ColorPlot if the dataset is one- or two-dimensional, respectively.

Parameters
  • fig (nata.plots.Figure, optional) – If provided, the plot is drawn on fig. The plot is drawn on axes if it is a child axes of fig, otherwise a new axes is created on fig. If fig is not provided, a new nata.plots.Figure is created.

  • axes (nata.plots.Axes, optional) – If provided, the plot is drawn on axes, which must be an axes of fig. If axes is not provided or is provided without a corresponding fig, a new nata.plots.Axes is created in a new nata.plots.Figure.

  • style (dict, optional) – Dictionary that takes a mix of style properties of nata.plots.Figure, nata.plots.Axes and any plot type (see nata.plots.types.LinePlot or nata.plots.types.ColorPlot).

  • interactive (bool, optional) – Controls wether interactive widgets should be shown with the plot to allow for temporal navigation. Only applicable if dataset has multiple iterations.

  • n (int, optional) – Selects the index of the iteration to be shown initially. Only applicable if dataset has multiple iterations, .

Returns

nata.plots.Figure or None – Figure with plot built based on dataset. Interactive widgets are shown with the figure if dataset has multiple iterations, in which case this method returns None.

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 the nata.plots.Figure.show() method.

>>> fig.show()

To draw a new plot on fig, we can pass it as an argument to the .plot() method. If axes 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])