get_lims_with_margin

PlasmaCalcs.plotting.plot_tools.lims.get_lims_with_margin(margin=None, *, x, ax=None, plot_settings=None, data_interval=None, skipna=False, scale=None)

returns lims to use for axis x, based on margin and the current data interval.

margin: None or number (greater than -0.5, probably close to 0.05) (default: None)
margin to use for x/y axis, as a fraction of the data interval for that axis.
None –> use matplotlib defaults
(e.g., plt.rcParams[“axes.xmargin”] or [“axes.ymargin”], or 0 if using imshow)
positive number –> pad around the data region, with this much whitespace.
E.g. 0.05 means adding 5% whitespace on each side.
Use this to zoom out.
negative number –> remove this much of the outer parts of the data region.
E.g. -0.2 means removing 20% space from each side.
Use this to zoom in.
For line plots, if also using robust, ymargin will be applied to the robust y lims.
(margin-related params share the same docstring, but refer to:
‘xmargin’: x-axis, ‘ymargin’: y-axis, ‘margin’: x and/or y-axis.)
x: ‘x’ or ‘y’
str telling the axis to get the data interval for.
ax: None or matplotlib axis object
the Axes to get the data interval from. None –> ax=plt.gca().
will use ax.xaxis or ax.yaxis, depending on x.
plot_settings: None or PlotSettings instance
if margin is None, get from plot_settings (or matplotlib defaults if None in plot_settings)
data_interval: None or [min, max]
if provided, use this instead of the actual range of data from the plot.
skipna: bool
whether to return None instead of nan if min or max would be nan.
scale: None, ‘linear’, or ‘log’
whether margin is in linear or log space. If None, use ax’s current scale.