I would like to plot a 1D profile of a 2D image along an arbitrary line. The code below loads the image data hosted on github and plots it:
import urllib
import numpy as np
import matplotlib.pyplot as plt
url = "https://gist.github.com/andreiberceanu/7141843/raw/0b9d50d3d417b1cbe651560470c098700df5a1fc/image.dat"
f = urllib.urlopen(url)
data = np.loadtxt(f)
plt.imshow(data)
The red line in the plot above was drawn by hand, as an example. I suppose one can parametrize it in the form a*x + b. I am also guessing some sort of interpolation is necessary, because the line passes though points which may not be part of the original 2D array of data.