Skip to content

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

Closed
@mwaskom

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

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