Skip to content

Repeated calls to scatter with identical data produce different axis limits #15955

Closed

Description

@mwaskom

Bug report

Bug summary

In trying to debug some tests, I discovered some strange behavior. I'm not certain it's a bug, but I can't really think of an explanation for it, so I'm reporting.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

f, ax = plt.subplots()
x, y = np.random.randn(2, 50)
ax.scatter(x, y)
xlim = ax.get_xlim()
ax.scatter(x, y)
print(xlim == ax.get_xlim())

Actual outcome

False

Expected outcome

True

Other observations

It appears to be scatter dependent. If I replace both calls to scatter with plot, it passes. Calling scatter then plot passes, but calling plot then scatter fails.

Matplotlib version

  • Operating system: MacOS
  • Matplotlib version: '3.1.1'
  • Matplotlib backend (print(matplotlib.get_backend())): notebook inline, reproduces on Agg
  • Python version: 3.7

Activity

  1. ImportanceOfBeingErnest commented on Dec 17, 2019

    @ImportanceOfBeingErnest
    Member

    The issue is #7413, part of which is fixed by #13642. Hence the above code will result in True in matplotlib 3.2.

  2. mwaskom commented on Dec 17, 2019

    @mwaskom
    Author

    Great!

  3. added this to the v3.2.0 milestone on Jun 16, 2020
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions