desc.plotting.plot_2d

desc.plotting.plot_2d(eq, name, grid=None, log=False, norm_F=False, ax=None, return_data=False, **kwargs)Source

Plot 2D cross-sections.

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.

  • norm_F (bool, optional) – Whether to normalize a plot of force error to be unitless. Vacuum equilibria are normalized by the gradient of magnetic pressure, while finite beta equilibria are normalized by the pressure gradient.

  • ax (matplotlib AxesSubplot, optional) – Axis to plot on.

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

  • **kwargs (dict, optional) –

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

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

    Valid keyword arguments are:

    • figsize: tuple of length 2, the size of the figure (to be passed to matplotlib)

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

    • title_fontsize: integer, font size of the title

    • xlabel_fontsize: float, fontsize of the xlabel

    • ylabel_fontsize: float, fontsize of the ylabel

    • cmap: str, matplotlib colormap scheme to use, passed to ax.contourf

    • levels: int or array-like, passed to contourf

Returns:

  • fig (matplotlib.figure.Figure) – Figure being plotted to.

  • ax (matplotlib.axes.Axes or ndarray of Axes) – Axes being plotted to.

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

Examples

../../_images/plot_2d.png
from desc.plotting import plot_2d
plot_2d(eq, 'sqrt(g)')