Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
Bug summary
I'm trying to produce a density plot of logarithmically spaced data. UsingNonUniformImage
used to work before matplotlib version3.10
, where I know exhibit a weirdly scaled axis.
Code for reproduction
importnumpyasnpimportmatplotlib.pyplotaspltfrommatplotlib.imageimportNonUniformImagex=np.linspace(0,1,2)y=np.geomspace(1e1,1e5,3)z=np.random.uniform(size=(len(x),len(y)))_, (ax1,ax2)=plt.subplots(ncols=2)# create the non-uniform imageim=NonUniformImage(ax1,extent=[0,1,1e0,1e6],origin="lower")im.set_data(x,y,z.T)ax1.add_image(im)ax1.set_yscale("log")ax1.set_ylim(1e0,1e6)# omitting this leads to very weird behaviorax1.set_title("NonUniformImage")# use pcolormesh to get reference imageax2.pcolormesh([0,0.5,1], [1e0,1e2,1e4,1e6],z.T)ax2.set_yscale("log")ax2.set_title("pcolormesh")
Actual outcome
The code above produces the following image
Expected outcome
I expect the left panel to look like the right panel, which was produced usingpcolormesh
. The reason I don't want to usepcolormesh
for these plots is that the quality in PDFs is often much worse (with lines showing up between patches) and the file size can easily be 10 times larger.
Additional information
I recently askeda related question on Stackoverflow, which has some additional details.
Operating system
OS/X
Matplotlib Version
3.10.0
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
3.12.8
Jupyter version
7.3.1
Installation
conda