Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect autoscaling of polar plot limits after scatter #7130

Closed
adeak opened this issue Sep 18, 2016 · 5 comments
Closed

Incorrect autoscaling of polar plot limits after scatter #7130

adeak opened this issue Sep 18, 2016 · 5 comments
Assignees
Milestone

Comments

@adeak
Copy link
Contributor

adeak commented Sep 18, 2016

In matplotlib 1.5.3 (installed with pip on Ubuntu, both over python 2.7.6 and 3.4.3) there seems to be an inconsistency of automatic axes limits in polar plots when a scatter plot is used. I first saw the issue in this question on Stack Overflow, and it boils down to this short example comparing plot and scatter:

import matplotlib.pyplot as plt
r = range(8)
ph = [-0.2]*len(r)

fig,(ax1,ax2) = plt.subplots(ncols=2,subplot_kw={'polar':True})
ax1.plot(ph,r,'o')
ax2.scatter(ph,r)
ax1.set_title('plot')
ax2.set_title('scatter')
plt.show()

polar plot vs scatter with automatic limits

The left axes plots the points using plot, and the axes limits are nicely adjusted. The right axes uses scatter, and most of the points are missing as the limits are not updated correctly to fit the data. Note that the default radial (y) top limit would be 1, so there is some rescaling going on, but it is incorrect. Setting ax2.set_ylim(0,max(r)) of course reproduces the scaling of the left axes.

@adeak adeak changed the title Buggy autoscaling of polar plot limits after scatter Incorrect autoscaling of polar plot limits after scatter Sep 18, 2016
@LindyBalboa
Copy link
Contributor

LindyBalboa commented Sep 18, 2016

Probably related to #6915

@adeak
Copy link
Contributor Author

adeak commented Sep 18, 2016

I had the same vague suspicion, but then again polar limit scaling shouldn't really involve logarithms. But plotting the same thing on a Cartesian axes shows that the automatic limits are different for plot and scatter, so I decided that it's likely due to scatter having an independent set of autoscale operations, and didn't reference the other issue. Thanks.

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Sep 19, 2016
@LindyBalboa
Copy link
Contributor

So far as we have come in the other thread, it looks like an issue of updating the Bbox which holds the dataLim(its). I haven't looked at the polar coordinate code in detail, but there are spots where it is more or less next to the logarithm code.

There will be two different paths to transforming the data from linear into log and polar scales, but regardless a common function is probably handling the dataLims at some point.

@efiring
Copy link
Member

efiring commented Sep 20, 2016

This is certainly related to #6915, but it's worse. With log scaling, the obvious breakage occurs only when the scale is switched to log after the call to scatter; but in the polar example here, the problem is occurring even when the projection is polar from the start.

@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017
@anntzer
Copy link
Contributor

anntzer commented Nov 4, 2019

This has been fixed as of master. Likely by #13642, though I didn't bother bisecting.

@anntzer anntzer closed this as completed Nov 4, 2019
@anntzer anntzer modified the milestones: needs sorting, v3.2.0 Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants