Skip to content

Wrong datalims with empty plots with shared axes #3118

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

Closed
pyatachyok opened this issue Jun 5, 2014 · 7 comments
Closed

Wrong datalims with empty plots with shared axes #3118

pyatachyok opened this issue Jun 5, 2014 · 7 comments

Comments

@pyatachyok
Copy link

import matplotlib.pyplot as plt

fig, (ax1, ax2) = plt.subplots(1, 2, True, False)
x1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
y1 = [x*x for x in x1]
ax1.plot(x1, y1)
x2=y2=[]
ax2.plot(x2, y2)
plt.show()

Now ax1.get_xlim() returns erroneous (-0.06, 0.06) because when bounding boxes of two plots are united, infinitely small bounding box of ax2 (Bbox('array([[ inf, inf],\n [-inf, -inf]])')) is considered infinitely large in transforms.BboxBase.union(). E. g. transforms.BboxBase.union([ax1.dataLim, ax2.dataLim]) returns Bbox('array([[-inf, -inf],\n [ inf, inf]])') which is incorrect.

This bug prevents correct display of two plots with shared axis while one of them has empty data.

@efiring
Copy link
Member

efiring commented Jun 5, 2014

This is present in 1.3.1, but fixed in master; 1.4 release is coming soon.

@tacaswell
Copy link
Member

When did this get fixed? This is a duplicate of another issue that I punted to 1.4.x a few days ago (#2492).

@efiring
Copy link
Member

efiring commented Jun 6, 2014

Good question; I don't know. But with this and with #2492, I can reproduce the problem with Anaconda, mpl 1.3.1, and not with mpl master on my Linux VM. There were a couple relevant-looking changes to transforms.py a year ago, but I don't think they actually affected this. I don't have time to track it down now, unfortunately.

@WeatherGod
Copy link
Member

Might it possibly be related to changes made recently to add_collections()?
IIRC, that caused datalims to always be calculated (for better or worse).

On Fri, Jun 6, 2014 at 1:42 PM, Eric Firing notifications@github.com
wrote:

Good question; I don't know. But with this and with #2492
#2492, I can reproduce
the problem with Anaconda, mpl 1.3.1, and not with mpl master on my Linux
VM. There were a couple relevant-looking changes to transforms.py a year
ago, but I don't think they actually affected this. I don't have time to
track it down now, unfortunately.


Reply to this email directly or view it on GitHub
#3118 (comment)
.

@efiring
Copy link
Member

efiring commented Jun 6, 2014

No, on two counts: first, because the examples here don't use collections; and second, because the change to add_collections defaults to causing datalims to be calculated, but does not require it.

@efiring
Copy link
Member

efiring commented Jun 6, 2014

26ed35b
Looks like that is the fix.
Is there an easy way to find the PR to which a commit like this corresponds?

@tacaswell
Copy link
Member

#2357 (found the commit in gitk and the child commit had that is the mesage).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants