I want to plot a color-coded histogram, where I input an array of arrays to represent the elements on the y-axis, while a simple 1D array on the x-axis to represent a phase.
The array of arrays to plot on the y-axis has a dimension, let's say, (100, 25)
, while the phase on the x-axis has 25 elements. Therefore, 100
is the number of elements that have to be color-coded for each of the 25 phase-bins.
I thought numpy.hist2d was suitable for this, but it only takes two same-sized arrays as input. I suppose I have to create a map of colors for each of the 25
arrays of 100
elements?
I really do not know how to approach this, because I have no experience with color-coded plots at all.
EDIT: I found this example as quite close to my case, except that I want a 2D plot where the Z-dimension is the color:
Also, the different histograms need to have the same color-coding. Here an example of my data:
phase (X-axis) = [ 0.01952176 0.04740999 0.07529822 0.10318645 0.13107468
0.15896291 0.18685114 0.21473937 0.2426276 0.27051583 0.29840406
0.32629229 0.35418052 0.38206875 0.40995698 0.43784521 0.46573344
0.49362167 0.5215099 0.54939813 0.57728636 0.60517459 0.63306282
0.66095105 0.68883928 0.71672751 0.74461574 0.77250397 0.8003922
0.82828043 0.85616866 0.88405689 0.91194512 0.93983335 0.96772158
0.99560981]
data to be color-coded in histograms (Y-axis) = [[ 0.01011273 0.00237802 -0.00227542 ..., nan nan nan]
[-0.00407017 -0.00317593 -0.00605734 ..., nan nan
nan]
[ 0.0166795 0.00798681 0.00075688 ..., 0.01022334 nan
nan]
...,
[ 0.00940512 nan nan ..., nan 0.00022334
0.00134779]
[ 0.00176177 0.00151938 nan ..., 0.05692114 0.00021122
-0.00003121]
[ nan 0.00455727 nan ..., 0.06812121 0.00011512
0.00016711]]