I am using Python with numpy, scipy, matplotlib.
I have two lists containing arrays of varying length, which for concreteness I will call x and y and say they look like (the actual arrays are on the order of ~1000 elements in length, and the actual lists have on the order of ~10s to ~100s of arrays):
x = [
np.array([0, 1, 2, 3, 4]),
np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4]),
np.array([0, 2 ,4])
]
y = [
np.array([0, 0, 1, 0, 0]),
np.array([1, 0.75, 0.5, 0.25, 0.0, 0.25, 0.5, 0.75, 1]),
np.array([0, 1, 0,])
]
Each x-array is sorted, and each y-array is sorted by the corresponding x-array, so len(x[i])==len(y[i]) is always True and x[i][j] always corresponds to y[i][j]. Each x-array ranges between the same two values (e.g., 0 and 4 in the above example).
I want to make a plot or save an image (if possible I want to know how to do both) where the i'th row is y[i] vs. x[i], with brightness corresponding to the y-value.
So e.g., in the above example:
- For the entire plot the x-axis would go from 0 to 4 (if I save an image instead of making a plot, then I'm not worried about explicitly having the x-values on an axis anyway, but I just know that the y-values of each row correspond to x-values going from 0 to 4).
- The 1st row would have the middle fifth of the row white, and the rest of the row black.
- The 2nd row would be divided into eights, with the middle of the row black and the two edges white, the rest varying shades of grey.
- The 3rd row would be divided into thirds, with the middle third of the row white and the two edge thirds of the row black.
I'm sure I could do this easily if Python or numpy has any stretch-array functions so that I could normalize the lengths of all of the arrays in x and y, or if matplotlib simply has a built-in function for exactly this type of plot. But I don't know whether either of these exist.
Does anyone know how to do this sort of thing (or for that matter, what this sort of plot would be called)?
Thanks very much for any help. Please let me know if my question is unclear.
---Further elaboration on above example--- If I go the route of stretching the arrays to all be of the same length, then the final arrays above might look something like (after stretching)
x = [
np.array([0, 0, 1, 1, 2, 3, 3, 4, 4]),
np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4]),
np.array([0,0,0,2,2,2,4,4,4])
]
y = [
np.array([0, 0, 0, 0, 1, 0, 0, 0, 0]),
np.array([1, 0.75, 0.5, 0.25,0, 0 .25,0 .5, 0.75, 1]),
np.array([0, 0, 0, 1, 1, 1, 0, 0, 0])
]
And the plot or image would look something like would look like an image version of y (I can't post the image without 10 reputation points).