Skip to content

Invalid polygon in stepfilled histogram when bottom is set #15782

Closed
@sauerburger

Description

@sauerburger

Bug report

Bug summary

The polygon perimeter created by hist() with histtype='stepfilled' in
combination with a non-None bottom argument has an invalid starting point.
This leads to a skewed lower edge of the first bin.

Code for reproduction

import matplotlib.pyplot as plt

# Data
data = [0, 0, 1, 1, 1]

# Bin edges
bins = [0, 1, 2]

plt.hist(data,
         bins=bins,
         bottom=[1, 2],  # Set lower edge
         histtype='stepfilled')

plt.savefig("example.png")

Actual outcome
actual

Expected outcome

The lower left point of the first bin should at coordinates (0, 1).

expected

Matplotlib version

  • Operating system: Debian (python:3.7 Docker image)
  • Matplotlib version: 3.1.2
  • Matplotlib backend (print(matplotlib.get_backend())): agg
  • Python version: 3.7.5
  • matplotlib installed via pip

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