Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Logscale Axis + NonUniformImage + GUI move tool = Distortion #27820

Copy link
Copy link
Closed
@DonaldHobson

Description

@DonaldHobson
Issue body actions

Bug summary

Run the code below, which uses set.xscale("log") and NonUniformImage. Choose the move tool (Arrows in all 4 directions) and try to pan the image around. Instead of panning, image distorts.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.image import NonUniformImage

chg=np.logspace(0,1,10)
chg1=chg[:,None]
chg2=chg[None,:]
g=chg1+chg2
g+=50*(np.add.outer(np.arange(10),np.arange(10))%2)
#checkerboard, to make effect clearer
fig,ax=plt.subplots()
ax.set_xscale("log")
ax.set_yscale("log")
im=NonUniformImage(ax,extent=[chg[0],chg[-1],chg[0],chg[-1]],origin="lower")


im.set_data(np.linspace(1,10,10),np.linspace(1,10,10),g)
ax.add_image(im)

plt.show()

Actual outcome

image
image

These are supposed to be the same image. I just used the pan tool.
But the aspect ratio has changed. And the boundary of the rightmost colour change has gone from 0.75 to 0.5.

Clicking and dragging produces behaviour that is visually obviously not-right.

Expected outcome

The image should pan around.

Additional information

No bug appears when I use a plt.imshow on the log scale axis. Or when I use the same NonUniformImage code without the logscale axis. The bug only appears with all 3 conditions are met.

I was trying to find a sensible way to display an image on log-log axes with constant screen space per pixel, when I discovered this bug.

Operating system

Ubuntu

Matplotlib Version

3.8.0

Matplotlib Backend

QtAgg

Python version

Python 3.11.5

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.