Cursor's Z coordinate display for NonUniformImage is inconsistent with image #18652
Comments
|
.. .does seem a problem. But out of curiosity, why are you using |
|
It's a general way to display data with a possibly uneven grid that should be faster than contouring methods, right? Is there a better way that I'm missing? |
|
|
|
@eldond When using |
|
@dopplershift Thank you, that makes sense. I should've caught that. Anyway, I can probably use pcolorfast, but my data would be more naturally described by Z(x, y); that is, I have x, y centers and I have to make up edges (pcolorfast doesn't accept When used correctly, pcolorfast isn't much slower than NonUniformImage: |
|
Have you tried using |
|
I tested it just now, but it doesn't change speed much and it doesn't put the Z (color) coordinate with the x, y coordinates. pcolorfast does everything I want except it's somewhat less convenient, but I can fix that. I'm going to make a wrapper for pcolorfast that accepts bin centers and makes up reasonable edges to go with them. |
def pcolorfast_centers(xc, yc, z, ax=None, **kw):
"""
Estimates bin edges given bin centers and passes them to pcolorfast
pcolorfast accepts x,y arrays that are one element longer than the corresponding dimensions of z,
which is awkward when the data are z = f(x, y). Yet pcolorfast is useful enough that we'd like to
use it, anyway.
:param xc: 1D float array
Bin centers in X; length should match first dimension of z
:param yc: 1D float array
Bin centers in Y; length should match second dimension of z
:param z: 2D float array
Z or color values at the bin centers
:param ax: Axes instance
Axes to plot in
:param kw: additional keywords passed to pcolorfast
"""
if ax is None:
ax = plt.gca()
inner_edges = (xc[:-1] + xc[1:]) / 2.0
x = np.append(np.append(inner_edges[0] - xc[1] + xc[0], inner_edges), inner_edges[-1] + xc[-1] - xc[-2])
inner_edges = (yc[:-1] + yc[1:]) / 2.0
y = np.append(np.append(inner_edges[0] - yc[1] + yc[0], inner_edges), inner_edges[-1] + yc[-1] - yc[-2])
print(np.shape(x), np.shape(xc), np.shape(z))
return ax.pcolorfast(x, y, z, **kw) |
|
Possibly |
|
Yeah, I don't see why not.... Seems a reasonable addition. |
|
Labeling as good first issue, as there's no API decision to be made here, and figuring out the correct value to display should be straightforward(?). |
|
Is this issue being worked on? If not, I'd like to work on it |
|
Nobody has spoken up to work on this. So go for it. |

Bug report
Bug summary
When using
matplotlib.image.NonUniformImage, the coordinates of the cursor are wrong: the Z-coordinate is inconsistent with the image (it appears to be based on howimshowwould display the data (flipped in Y)).The Z values also don't change at the visible boundaries between "pixels" or cells, they change somewhere else that might be consistent with different cell alignment to the x,y values.
Code for reproduction
Actual outcome
Notice that when the cursor is at the top right (value should approach 400), the value is about 200. When the cursor is at the bottom right (value should be about 200), the value approaches 400.


Expected outcome
It should be like the actual outcome, but with the correct Z-coordinates reported: should be close to 400 at the top right and close to 200 at the bottom right.
Matplotlib version
print(matplotlib.get_backend())): Qt5Agg, TkAggThe text was updated successfully, but these errors were encountered: