lib5c.plotters.curve_fits module¶
Module for plotting curves fitted to x-y graphs.
-
lib5c.plotters.curve_fits.
plot_fit
(x, y, fit, n_points=None, logx=True, logy=True, hexbin=True, colors=None, linewidth=4, xlim=None, ylim=None, **kwargs)[source]¶ Plots a fit over data.
- Parameters
y (x,) – The data points.
fit (function or np.ndarray or dict) – If a function is passed, it should return an estimate of y as a function of x. If an
np.ndarray
is passed, it should be parallel tox
and should contain the estimate of y for each x value. Pass a dict of functions ornp.ndarray
to plot multiple estimates.n_points (int, optional) – Pass an integer to subsample
x
with this many points when drawing the curve. Pass None to draw the curve using all values inx
.logy (logx,) – Log the x- and/or y-axis.
hexbin (bool) – Pass True to plot a hexbin plot instead of a scatterplot.
colors (dict) – If
fit
is a dict, pass a dict mapping the keys offit
to valid matplotlib colors to force the colors of the curves.linewidth (float) – Line width to draw the fit with.
kwargs (kwargs) – Typical plotter kwargs.
- Returns
The axis plotted on.
- Return type
pyplot axis
Notes
If both xlim and ylim are passed as kwargs and hexbin=True, this function will attempt to set the extent of the hexbin plot using the xlim and ylim.