I'm trying to get the data values along a line (like in this hint). That example uses imshow(), but I'm currently using pcolormesh() to plot.
I'm finding that the get_array() function, to grab plotted data from pcolormesh() is returning a 1-D, flattened array of my data, instead of the original (or truncated) 2-D data.
For example:
D = np.genfromtxt(DataFilePath, skip_header=4, delimiter=',', unpack=True)
print( D.shape )
: (500, 500)
...more code...
img = ax[0].pcolormesh( np.arange( len(D[0,:]) ), np.arange(len(D[:,0])), D)
>>> D
: array([[ 42.38, 41.93, 41.92, ..., 41.73, 41.74, 41.51],
[ 41.88, 42.24, 42.21, ..., 41.88, 41.67, 41.64],
[ 42.4 , 41.47, 41.49, ..., 41.92, 42.07, 41.49],
...,
[ 44.24, 44.14, 44.17, ..., 40.2 , 40.68, 40.67],
[ 44.59, 44.24, 44.3 , ..., 40.91, 40.92, 40.95],
[ 44.2 , 44.27, 44.27, ..., 40.82, 40.91, 40.94]])
>>> img.get_array()
: array([ 42.38, 41.93, 41.92, ..., 40.85, 40.91, 40.92])
Since I'm trying to grab user-clicks on the plot and then re-plot using the clicked data values (like in this hint), I would like to use a function/class which won't have global access to the original data, but does have access to the img object.
Any idea how I get the 2D data from pcolormesh() using only the img(QuadMesh) object? It doesn't even seem to have the x/y length/shape values, for me to reconstruct the data from the 1-D get_array().
Thanks!
pcolormeshrannp.ravel()on the data and stroed it inget_array()- any way tounravel?img(QuadMesh) object, but can't access the original Data array.imgattributes the @unutbu mentions are the way go.