Skip to content

Wrong datalims with empty plots with shared axes #3118

Closed

Description

@pyatachyok
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.

Activity

  1. efiring commented on Jun 5, 2014

    @efiring
    Member

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

  2. tacaswell commented on Jun 6, 2014

    @tacaswell
    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).

  3. efiring commented on Jun 6, 2014

    @efiring
    Member

    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.

  4. WeatherGod commented on Jun 6, 2014

    @WeatherGod
    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)
    .

  5. efiring commented on Jun 6, 2014

    @efiring
    Member

    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.

  6. efiring commented on Jun 6, 2014

    @efiring
    Member

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

  7. tacaswell commented on Jun 6, 2014

    @tacaswell
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions