Skip to content

Stackplot fails for small numbers #17633

Closed
@svaberg

Description

@svaberg

Bug report

Bug summary

It appears that stackplot fails for small numbers in version 3.2.1, or at least something goes wrong in my clean installation, see figures below.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

x =  [0, 1]
y1 = 1e-8*np.ones_like(x)
y2 = 1e-9*np.ones_like(x)

fig, axs = plt.subplots(2, 1)
axs[0].stackplot(x, y1, y2)  # This plot is fine
axs[1].stackplot(x, y1/10, y2/10)  # This plot is wrong
plt.show()

Actual outcome
image
Something went wrong in the second subplot.

Expected outcome
Expected this, as generated with matplotlib version 3.1.2
mpl312

Matplotlib version

  • Operating system: macOS 10.12.6 (Sierra)
  • Matplotlib version: 3.2.1
  • Matplotlib backend (print(matplotlib.get_backend())): MacOSX
  • Python version: 3.8.3

Created a conda environment with only thenumpy package, then installed matplotlib with pip.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions