I have a text file containing 500x500 intensity values. I'm attempting to produce a 3D plot of this data using Python-XY. Only a particular part of this 500x500 array is meant to be plotted (235:268, 210:280).
Here is one of many attempts of the Python-XY code so far:
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
from matplotlib.mlab import griddata
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
data = np.genfromtxt('Fig2.txt')
X = np.linspace(235,268,num=33)
Y = np.linspace(210,280,num=70)
x,y = np.meshgrid (X,Y)
Z = data[235:268,210:280]
ax.plot_surface(x,y,Z, rstride=1, cstride=1, cmap=cm.jet)
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
I have attempted a number of different codes to produce this plot but there is a particular error that keeps popping up:
ValueError: shape mismatch: two or more arrays have incompatible dimensions on axis 0.
I'm assuming this is referring to the X and Y axis being incompatible but I'm unsure as to why this is. Is there anywhere in particular that I am going wrong here?