I want to make a surface plot from a two dimensional array, where the z-values are stored (similar to an image where the pixel values are given).
My data is an 512x512 array like:
Z
Out[85]:
array([[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]])
The values of interest are in the center part of the picture.
Image where only the central circular region is to be plotted as a surface plot
I did the surface plot with:
X = np.arange(1, 513)
Y = np.arange(1, 513)
X, Y = np.meshgrid(X, Y)
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, vmin=0.01)
plt.show()
The result is:
Resulting Image without any masking or thresholding
Apart from a bad style I only want to plot the circular central region and not plotting the outer square region where all values are zero.
How can I give a threshold or a mask to the values? Or is there a much better approach? I would really appreciate an example since I am pretty new to python/numpy ect.
Thank you very much!