Curve fitting (non-linear least-square) to a 2D contour plot using python

Nita Ghosh
3 min readFeb 26, 2022

In this post, I’ll outline how to fit a 2D contour plot using the non-linear least-square curve fitting method. I’ll use a manually defined simple 2D contour plot. But this procedure can be extended to any 2D contour, in principle.

  1. Import libraries: We need numpy, matplotlib libraries along with curve_fit function from scipy.optimize module. Let’s import the libraries.
#import librariesimport numpy as np
from scipy.optimize import curve_fit
import…

--

--