solarwindpy.fitfunctions.plotsο
Plotting utilities for solarwindpy.fitfunctions.
This module contains FFPlot, a helper for visualizing fitted
models, residuals and associated annotations.
Classes
|
|
|
|
|
- class AxesLabels(x, y, z)
Bases:
tuple- count(value, /)
Return number of occurrences of value.
- index(value, start=0, stop=sys.maxsize, /)
Return first index of value.
Raises ValueError if the value is not present.
- x
Alias for field number 0
- y
Alias for field number 1
- z
Alias for field number 2
- class LogAxes(x, y)
Bases:
tuple- count(value, /)
Return number of occurrences of value.
- index(value, start=0, stop=sys.maxsize, /)
Return first index of value.
Raises ValueError if the value is not present.
- x
Alias for field number 0
- y
Alias for field number 1
- class FFPlot(observations, y_fit, TeX_info, fit_result, fitfunction_name='')[source]
Bases:
object- __init__(observations, y_fit, TeX_info, fit_result, fitfunction_name='')[source]
Container for plotting a
FitFunction.- Parameters:
observations (
Observations) β Observed data used in the fit.y_fit (array-like) β Model evaluated at the observed
xvalues.TeX_info (
TeXinfo) β Object describing the fit for annotation.fit_result (scipy.optimize.OptimizeResult) β Result object returned from the fitting routine.
fitfunction_name (str, optional) β Name of the originating fit function.
- property labels
- property log
- property observations
- property fitfunction_name
- property fit_result
- property path
- property TeX_info
- property y_fit
- set_fitfunction_name(new)[source]
Set the descriptive name for saved plots.
- set_fit_result(new)[source]
Store the optimization result object.
- set_observations(observations, y_fit)[source]
Set raw and fitted values used for plotting.
- plot_raw(ax=None, plot_window=True, edge_kwargs=None, **kwargs)[source]
Plot the observations used in the fit from raw data.
Plot from
self.observations.raw.x(),self.observations.raw.y(),self.observations.raw.w().- Parameters:
edge_kwargs (None, dict) β If not None, plot edges on the window using these kwargs.
- plot_used(ax=None, plot_window=True, edge_kwargs=None, **kwargs)[source]
Plot the observations used in the fit from used data.
Plot from
self.observations.used.x(),self.observations.used.y(), andself.observations.used.w().
- plot_fit(ax=None, annotate=True, annotate_kwargs=None, **kwargs)[source]
Plot the fit.
- plot_raw_used_fit(ax=None, drawstyle=None, annotate=True, raw_kwargs=None, used_kwargs=None, fit_kwargs=None, annotate_kwargs=None)[source]
Make a plot of the raw observations, observations in fit, and the fit.
Combines the outputs of
self.plot_raw(),self.plot_used(), andself.plot_fit().- Parameters:
ax (None, mpl.Axes.axis_subplot)
drawstyle (str, None) β mpl drawstyle, shared by
self.plot_raw()andself.plot_used(). If None, defaults to βsteps-midβ.annotate (True) β If True, add fit info to the annotation using ax.text.
raw_kwargs (dict) β Passed to ax.plot(**kwargs) in
self.plot_raw().used_kwargs (dict) β Passed to ax.plot(**kwargs) in
self.plot_used().fit_kwargs (dict) β Passed to ax.plot(**fit_kwargs) for plotting fit.
annotate_kwargs β Passed to ax.text.
- Returns:
ax
- Return type:
mpl.Axes.axis_subplot
- plot_residuals(ax=None, pct=True, subplots_kwargs=None, kind='both', **kwargs)[source]
Plot residuals for the data used in the fit.
Residuals are shown on a symlog scale with
linthresh=10. By default they are expressed as percentages of the fitted model.- Parameters:
ax (mpl.axes.Axes, optional) β Axis to draw on. If
Nonea new figure and axis are created.pct (bool, default True) β If
True, show residuals as percentages.subplots_kwargs (dict, optional) β Passed to
plt.subplotswhenaxisNone.kind ({'simple', 'robust', 'both'}, default "both") β Which residuals to plot.
**kwargs β Additional keyword arguments passed to
ax.plot.
- Returns:
ax β Axis with residuals plotted.
- Return type:
mpl.axes.Axes
- plot_raw_used_fit_resid(annotate=True, fit_resid_axes=None, figsize=(6, 4), resid_kwargs=None, **kwargs)[source]
Make a stacked fit, residual plot.
- Parameters:
annotate (bool) β If True, add fit annotation to axis.
fit_resid_axes (None, 2-tuple of mpl.axis.Axis) β If not None, (fit, resid) axis pair to plot the (raw, used, fit) and residual on, respectively. Otherwise, use GridSpec to build a pair of axes where the raw_used_fit axis is 3 times the resid_axis. Additionally, if fit_resid_axes is None, the hax and rax will share an x-axis and haxβs x-ticks and label will be set invisible.
figsize β Any valid argument for
plt.figure(figsize=figsize)(). This code was developed with default size 6x4 and this size helps accomodate annotation. So we persist it here.resid_kwargs (dict, None) β Passed to
{self.__class__.__name__}.plot_residuals().kwargs β Passed to
{self.__class__.__name__}.plot_raw_used_fit().
- Returns:
hax (mpl.axis.Axis) β Axis with raw observations, used observations, and fit plotted on it.
rax (mpl.axis.Axis) β Axis with residuals plotted on it.
- residuals(pct=False, robust=False)[source]
Calculate the fit residuals.
If pct, normalize by fit yvalues.
- set_labels(**kwargs)[source]
Set or update x, y, or z labels.
Any label not specified in kwargs is propagated from self.labels.<x, y, or z>.
- set_log(**kwargs)[source]
Set
LogAxes.Only used for determining if weights should be \(w/(y \ln(10))\).
- set_TeX_info(new)[source]
Assign
TeXinfoused for annotations.