python - 2D plot using 1D arrays without griddata() -
i trying plot function of 2 variables using matplotlib
. function stored in 3 1d arrays x
, y
, f
corresponding x-coordinate, y-coordinate , value of function. possible plot these data contour plot? before saw solution griddata()
, avoid interpolating since x , y coordinates defined.
take @ the contour demo of matplotlib docs. since can calculate function f
@ given point:
delta = 0.025 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) x, y = np.meshgrid(x, y) f = your_function(x.ravel(), y.ravel()) cs = plt.contour(x, y, f.reshape(x.shape)) plt.clabel(cs, inline=1, fontsize=10)
Comments
Post a Comment