def plot_scalar(step, var, field=None, axis=None, set_cbar=True, **extra):
if var in phyvars.FIELD:<EOL><INDENT>meta = phyvars.FIELD[var]<EOL><DEDENT>else:<EOL><INDENT>meta = phyvars.FIELD_EXTRA[var]<EOL>meta = phyvars.Varf(misc.baredoc(meta.description), meta.dim)<EOL><DEDENT>if step.geom.threed:<EOL><INDENT>raise NotAvailableError('<STR_LIT>')<EOL><DEDENT>xmesh, ymesh, fld = get_meshes_fld(step, var)<EOL>xmin, xmax = xmesh.min(), xmesh.max()<EOL>ymin, ymax = ymesh.min(), ymesh.max()<EOL>if field is not None:<EOL><INDENT>fld = field<EOL><DEDENT>if conf.field.perturbation:<EOL><INDENT>fld = fld - np.mean(fld, axis=<NUM_LIT:0>)<EOL><DEDENT>if conf.field.shift:<EOL><INDENT>fld = np.roll(fld, conf.field.shift, axis=<NUM_LIT:0>)<EOL><DEDENT>fld, unit = step.sdat.scale(fld, meta.dim)<EOL>if axis is None:<EOL><INDENT>fig, axis = plt.subplots(ncols=<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>fig = axis.get_figure()<EOL><DEDENT>if step.sdat.par['<STR_LIT>']['<STR_LIT>']:<EOL><INDENT>rcmb = step.sdat.par['<STR_LIT>']['<STR_LIT>']<EOL>xmax = rcmb + <NUM_LIT:1><EOL>ymax = xmax<EOL>xmin = -xmax<EOL>ymin = -ymax<EOL>rsurf = xmax if step.timeinfo['<STR_LIT>'] > <NUM_LIT:0>else step.geom.r_mesh[<NUM_LIT:0>, <NUM_LIT:0>, -<NUM_LIT:3>]<EOL>cmb = mpat.Circle((<NUM_LIT:0>, <NUM_LIT:0>), rcmb, color='<STR_LIT>', zorder=<NUM_LIT:0>)<EOL>psurf = mpat.Circle((<NUM_LIT:0>, <NUM_LIT:0>), rsurf, color='<STR_LIT>', zorder=<NUM_LIT:0>)<EOL>axis.add_patch(psurf)<EOL>axis.add_patch(cmb)<EOL><DEDENT>extra_opts = dict(<EOL>cmap=conf.field.cmap.get(var),<EOL>vmin=conf.plot.vmin,<EOL>vmax=conf.plot.vmax,<EOL>norm=mpl.colors.LogNorm() if var == '<STR_LIT>' else None,<EOL>rasterized=conf.plot.raster,<EOL>shading='<STR_LIT>' if conf.field.interpolate else '<STR_LIT>',<EOL>)<EOL>extra_opts.update(extra)<EOL>surf = axis.pcolormesh(xmesh, ymesh, fld, **extra_opts)<EOL>cbar = None<EOL>if set_cbar:<EOL><INDENT>cbar = plt.colorbar(surf, shrink=conf.field.shrinkcb)<EOL>cbar.set_label(meta.description +<EOL>('<STR_LIT>' if conf.field.perturbation else '<STR_LIT>') +<EOL>('<STR_LIT>'.format(unit) if unit else '<STR_LIT>'))<EOL><DEDENT>if step.geom.spherical or conf.plot.ratio is None:<EOL><INDENT>plt.axis('<STR_LIT>')<EOL>plt.axis('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>axis.set_aspect(conf.plot.ratio / axis.get_data_ratio())<EOL><DEDENT>axis.set_adjustable('<STR_LIT>')<EOL>axis.set_xlim(xmin, xmax)<EOL>axis.set_ylim(ymin, ymax)<EOL>return fig, axis, surf, cbar<EOL>
Plot scalar field.

    Args:
        step (:class:`~stagpy.stagyydata._Step`): a step of a StagyyData
            instance.
        var (str): the scalar field name.
        field (:class:`numpy.array`): if not None, it is plotted instead of
            step.fields[var].  This is useful to plot a masked or rescaled
            array.  Note that if conf.scaling.dimensional is True, this
            field will be scaled accordingly.
        axis (:class:`matplotlib.axes.Axes`): the axis objet where the field
            should be plotted.  If set to None, a new figure with one subplot
            is created.
        set_cbar (bool): whether to add a colorbar to the plot.
        extra (dict): options that will be passed on to
            :func:`matplotlib.axes.Axes.pcolormesh`.
    Returns:
        fig, axis, surf, cbar
            handles to various :mod:`matplotlib` objects, respectively the
            figure, the axis, the surface returned by
            :func:`~matplotlib.axes.Axes.pcolormesh`, and the colorbar returned
            by :func:`matplotlib.pyplot.colorbar`.