desc.plotting.plot_3d

desc.plotting.plot_3d(eq, name, grid=None, log=False, normalize=None, fig=None, return_data=False, compute_kwargs=None, **kwargs)Source

Plot 3D surfaces.

Parameters:
  • eq (Equilibrium, Surface) – Object from which to plot.

  • name (str) – Name of variable to plot.

  • grid (Grid, optional) – Grid of coordinates to plot at.

  • log (bool, optional) – Whether to use a log scale.

  • normalize (str, optional) – Name of the variable to normalize name by. Default is None.

  • fig (plotly.graph_objs._figure.Figure, optional) – Figure to plot on.

  • return_data (bool) – If True, return the data plotted as well as fig,ax

  • compute_kwargs (dict, optional) – Additional keyword arguments to pass to eq.compute.

  • **kwargs (dict, optional) –

    Specify properties of the figure, axis, and plot appearance e.g.:

    plot_X(figsize=(4,6), cmap="RdBu")
    

    Valid keyword arguments are:

    • figsize: tuple of length 2, the size of the figure in inches

    • component: str, one of [None, ‘R’, ‘phi’, ‘Z’], For vector variables, which element to plot. Default is the norm of the vector.

    • title: title to add to the figure.

    • cmap: string denoting colormap to use.

    • levels: array of data values where ticks on colorbar should be placed.

    • alpha: float in [0,1.0], the transparency of the plotted surface

    • showscale: Bool, whether or not to show the colorbar. True by default.

    • showgrid: Bool, whether or not to show the coordinate grid lines. True by default.

    • showticklabels: Bool, whether or not to show the coordinate tick labels. True by default.

    • showaxislabels: Bool, whether or not to show the coordinate axis labels. True by default.

    • zeroline: Bool, whether or not to show the zero coordinate axis lines. True by default.

    • field: MagneticField, a magnetic field with which to calculate Bn on the surface, must be provided if Bn is entered as the variable to plot.

    • field_grid: MagneticField, a Grid to pass to the field as a source grid from which to calculate Bn, by default None.

Returns:

  • fig (plotly.graph_objs._figure.Figure) – Figure being plotted to

  • plot_data (dict) – Dictionary of the data plotted, only returned if return_data=True

Examples

from desc.plotting import plot_3d
from desc.grid import LinearGrid
grid = LinearGrid(
        rho=0.5,
        theta=np.linspace(0, 2 * np.pi, 100),
        zeta=np.linspace(0, 2 * np.pi, 100),
        axis=True,
    )
fig = plot_3d(eq, "|F|", log=True, grid=grid)