Skip to content

Commit

Permalink
ENH: show the fit on top of data points.
Browse files Browse the repository at this point in the history
As discussed on the mailinglist the default for ModelResult.plot_fit()
has been changed to show the fit on top of the data points.

(see https://groups.google.com/forum/#!topic/lmfit-py/rekwbFVJy2c)
  • Loading branch information
reneeotten committed Dec 7, 2017
1 parent 0dba26f commit 58e52dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lmfit/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1649,11 +1649,6 @@ def plot_fit(self, ax=None, datafmt='o', fitfmt='-', initfmt='--',
**{independent_var: x_array_dense}),
initfmt, label='init', **init_kws)

ax.plot(
x_array_dense,
self.model.eval(self.params, **{independent_var: x_array_dense}),
fitfmt, label='best-fit', **fit_kws)

if yerr is None and self.weights is not None:
yerr = 1.0/self.weights
if yerr is not None:
Expand All @@ -1662,6 +1657,11 @@ def plot_fit(self, ax=None, datafmt='o', fitfmt='-', initfmt='--',
else:
ax.plot(x_array, self.data, datafmt, label='data', **data_kws)

ax.plot(
x_array_dense,
self.model.eval(self.params, **{independent_var: x_array_dense}),
fitfmt, label='best-fit', **fit_kws)

ax.set_title(self.model.name)
if xlabel is None:
ax.set_xlabel(independent_var)
Expand Down

0 comments on commit 58e52dd

Please sign in to comment.