plot2

threadcount.lmfit_ext.plot2(self, datafmt='o', fitfmt='-', initfmt='--', xlabel=None, ylabel=None, yerr=None, numpoints=None, fig=None, data_kws=None, fit_kws=None, init_kws=None, ax_res_kws=None, ax_fit_kws=None, fig_kws=None, show_init=False, parse_complex='abs', title=None)[source]

Plot the fit results and residuals using matplotlib.

The method will produce a matplotlib figure (if package available) with both results of the fit and the residuals plotted. If the fit model included weights, errorbars will also be plotted. To show the initial conditions for the fit, pass the argument show_init=True.

Parameters:
  • datafmt (str, optional) – Matplotlib format string for data points.

  • fitfmt (str, optional) – Matplotlib format string for fitted curve.

  • initfmt (str, optional) – Matplotlib format string for initial conditions for the fit.

  • xlabel (str, optional) – Matplotlib format string for labeling the x-axis.

  • ylabel (str, optional) – Matplotlib format string for labeling the y-axis.

  • yerr (numpy.ndarray, optional) – Array of uncertainties for data array.

  • numpoints (int, optional) – If provided, the final and initial fit curves are evaluated not only at data points, but refined to contain numpoints points in total.

  • fig (matplotlib.figure.Figure, optional) – The figure to plot on. The default is None, which means use the current pyplot figure or create one if there is none.

  • data_kws (dict, optional) – Keyword arguments passed to the plot function for data points.

  • fit_kws (dict, optional) – Keyword arguments passed to the plot function for fitted curve.

  • init_kws (dict, optional) – Keyword arguments passed to the plot function for the initial conditions of the fit.

  • ax_res_kws (dict, optional) – Keyword arguments for the axes for the residuals plot.

  • ax_fit_kws (dict, optional) – Keyword arguments for the axes for the fit plot.

  • fig_kws (dict, optional) – Keyword arguments for a new figure, if a new one is created.

  • show_init (bool, optional) – Whether to show the initial conditions for the fit (default is False).

  • parse_complex ({'abs', 'real', 'imag', 'angle'}, optional) – How to reduce complex data for plotting. Options are one of: ‘abs’ (default), ‘real’, ‘imag’, or ‘angle’, which correspond to the NumPy functions with the same name.

  • title (str, optional) – Matplotlib format string for figure title.

Return type:

matplotlib.figure.Figure

See also

ModelResult.plot_fit

Plot the fit results using matplotlib.

ModelResult.plot_residuals

Plot the fit residuals using matplotlib.

Notes

The method combines ModelResult.plot_fit and ModelResult.plot_residuals. If yerr is specified or if the fit model included weights, then matplotlib.axes.Axes.errorbar is used to plot the data. If yerr is not specified and the fit includes weights, yerr set to 1/self.weights. If model returns complex data, yerr is treated the same way that weights are in this case. If fig is None then matplotlib.pyplot.figure(**fig_kws) is called, otherwise fig_kws is ignored.