I am trying to produce a contour plot using axis 0, 1, and 3 (x, y, and z). However, I am having trouble to interpolating the z-values on the grid.
The data is:
0.8917 3.3825 7.755 0.3709
3.2707 3.3706 8.0704 0.5669
4.6345 0.5754 7.9279 0.5383
1.4717 0.8609 7.9363 0.5256
9.1615 3.6124 7.8407 0.5833
10.613 0.8782 7.8781 0.537
7.5193 0.768 7.8407 0.5833
-2.2248 8.29 7.6937 0.3578
0.207 8.5664 7.973 0.5345
1.9296 5.8915 8.0567 0.534
-1.2482 6.0459 7.973 0.5345
3.5835 8.0449 7.755 0.371
6.0573 8.8033 7.9363 0.5256
7.8859 6.2071 7.9279 0.5383
4.7833 5.9905 8.0704 0.5669
12.0913 0.0247 8.4997 -0.9643
0.0852 10.2797 8.5307 -0.9526
-2.7929 5.2947 8.5307 -0.9526
3.3877 5.0497 8.7554 -0.9357
3.1277 1.603 7.5125 -1.007
9.0397 1.7865 7.4696 -0.9899
0.3865 6.7824 7.4898 -1.0024
6.2426 6.9982 7.5125 -1.007
-0.02 3.5714 6.0746 -0.9935
6.0881 3.4906 6.3915 -0.9577
-3.0798 8.7837 6.0443 -0.9931
Here I am trying to produce the 2D grid and interpolate the z-values in the grid:
x_y_col = contour_data[[0,1]].to_numpy()
points = x_y_col
values =contour_data[[3]].to_numpy()
x = np.linspace(-5,10,10)
y = np.linspace(0,10,10)
grid_x,grid_y = np.meshgrid(x,y)
Z= griddata(points, values, (grid_x, grid_y), method='cubic')
However, when I tried to print the interpolated data it returns some of the NaN values like this:
[[[ nan]
[ nan]
[ nan]
[ nan]
[ nan]
[ nan]
[ nan]
[ nan]
[ nan]
[ nan]]
[[ nan]
[ nan]
[ nan]
[ nan]
[ 0.20175338]
[-0.78055115]
[ 0.01861935]
[ 0.29941125]
[-0.21535268]
[ 0.13910528]]
[[ nan]
[ nan]
[ nan]
[ nan]
[ 0.19295743]
[-0.44071375]
[-0.85967443]
[-0.71360517]
[-1.15037581]
[ 0.40896608]]
[[ nan]
[ nan]
[ nan]
[-0.9840817 ]
[ 0.76255707]
[ 0.54118907]
[-0.54032303]
[-1.02423615]
[-0.42427756]
[ nan]]
Is there something wrong with my code? The Z values also need to be in 2D array for me to plot it
