I am trying to plot profiles from an interpolated data. To begin with my data is three columns x,y,c.
First I interpolate the data onto a regular grid using:
xi , yi = np.linspace(np.min(X), np.max(X),300) , np.linspace(np.min(Y), np.max(Y),300)
xi, yi = np.meshgrid(xi, yi)
zi = scipy.interpolate.griddata((X, Y), C , (xi, yi),method='nearest')
now following the thread: How to extract an arbitrary line of values from a numpy array?
I want to plot the values at X = 5 for Y = -4,4
x0, y0 = 5, -4 # These are in _pixel_ coordinates!!
x1, y1 = 5, 4
num = 50
x, y = np.linspace(x0, x1, num), np.linspace(y0, y1, num)
#Getting values at that location
zi2 = scipy.ndimage.map_coordinates(np.transpose(zi), np.vstack((x,y)))
#Plotting
fig, axes = plt.subplots(nrows=2)
axes[0].imshow(zi, vmin=np.min(C), vmax=110, origin='lower',extent= [np.min(X), np.max(X), np.min(Y), np.max(Y)])
axes[0].plot([x0, x1], [y0, y1], 'ro-')
axes[0].axis('image')
axes[1].plot(y,zi2)
plt.show()
I get the following plot which is not looking the same as the way contour is behaving.