Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix log scaling for pcolor and pcolormesh#29783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
You changed pcolor and pcolormesh, but are showing an example with scatter. What do the before and after plots look like? I can't really evaluate what has changed. |
Gah, thanks for spotting that 🤦 . I've updated the script, and added the timings I get. |
I guess I was more interested in the visual change, which I think this has? |
Okay? I guess I'm not sure how you choose ymin in the case that |
If one scatters the same x/y points used for the I'm not sure why importnumpyasnpimportmatplotlib.pyplotaspltx=np.arange(512,dtype=float)y=np.arange(512,dtype=float)print(y[0])z=np.arange(len(x)*len(y)).reshape(len(x),len(y))fig,axs=plt.subplots(ncols=2)ax=axs[0]ax.pcolormesh(x,y,z)ax.set_yscale("log")ax=axs[1]ax.scatter(x,y)ax.set_yscale("log")plt.show() |
T.b.c: This may be a center vs. edge topic. Plot only chooses limits based on the points (centers of the mesh). The mesh may choose limits based on its edges. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think I agree this is an improvement.
However, I'm a little concerned that data at zero is being represented at all in this scale. I see this pretty often when folks dopcolormesh(k, t, spectra)
andk[0]=0
, and the left hand limit makes the left-most bin ends up spread out arbitrarily wide. It would be nice if thisexplicitly indicated what the xmin would be set to, based on what is ink
, whereas I still have no idea based on this.
I believe |
Since this has two approvals with no changes since either, I'll merge this tomorrow unless there are any objections before then. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
a3aad58
intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
PR summary
Fixes#29615. Instead of explicitly setting the data lims with the min/max values of the edges, pass all the values to allow
update_datalim
to handle them appropriately. I also took the oppurtunity to de-duplicate the limit setting code inpcolor()
andpcolormesh()
, since I needed to update them to match anyway.The tests are both very similar, but I couldn't think of a good way to de-duplicate testing
pcolor
andpcolormesh
- suggestions very welcome.In terms of performance, running the below script locally I see ~10% slowdown with pcolormesh, and no significant slowdown with pcolor.
pcolormesh
Before:
Mean: 0.08725245793660481
Stdev: 0.005315622438177594
After:
Mean: 0.09809311230977376
Stdev: 0.006966432274025711
pcolor
Before:
Mean: 1.8416528701782227
Stdev: 0.020062453166251135
After:
Mean: 1.8436991373697917
Stdev: 0.021314677717322438
PR checklist