Im looking for a pythonic way to plot an array whereby the x-axis values fluctuate. All of my data is read in from a h5 file (several rows and columns) such that:
data = h5py.File("file",'r')
dset = data['/DATA/DATA/'][:]
I now have an array with shape (25, 432). 432 data points in 23 separate data entries. The data are spectral reflectance data collected across 432 spectral bands, taken at 23 points.
I create an x-axis for the data based using the band numbers using:
xvals = numpy.arange(1, 433, 1)
I can plot all of this data by calling each one separately. Its not very elegant but its does the job, such that:
plt.plot(xvals, values[0])
plt.plot(xvals, values[1])
plt.plot(xvals, values[2])
However, the data contains some erroneous values. I can omit them by slicing the arrays, such as:
values = dset[np.logical_and(dset<1, dset>0)]
But this changes the length of each array so that each one may be a unique length. I can slice the x-axis in a similar way but this won't be applicable to all of the arrays.
Essentially I have:
a = [[1,2,3,-1,5,6],
[1,-1,3,4,5,6],
[1,2,3,4,-1,6]]
x = [1,2,3,4,5,6]
If I remove the -1 values, x is too long and I cannot plot them as they "do not have the same first dimension". However, x will be different for each array within a.
Is there a pythonic way of plotting the data all in one plot, whereby I can omit erroneous data (outside the range 0-1) from the 'dset' and adjust the number of data points in the x-axis accordingly?
