Plot Residual#

Fit an affine function and plot the residual.

import numpy as np
import hyperspy.api as hs

Create a signal:

data = np.arange(1000, dtype=np.int64).reshape((10, 100))
s = hs.signals.Signal1D(data)

Add noise:

s.add_poissonian_noise(random_state=0)

Create model:

m = s.create_model()
line = hs.model.components1D.Expression("a * x + b", name="Affine")
m.append(line)

Fit for all navigation positions:

m.multifit()
0%|          | 0/10 [00:00<?, ?it/s]

Plot the fitted model with residual:

m.plot(plot_residual=True)
  • plot residual
  • Signal

sphinx_gallery_thumbnail_number = 2

Total running time of the script: (0 minutes 0.746 seconds)

Gallery generated by Sphinx-Gallery