8000 bars in plt.bar graph centered on "left" value · Issue #8882 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
bars in plt.bar graph centered on "left" value #8882
Closed
@skjaeve

Description

@skjaeve

Bug report

Bug summary

Docstring for plt.bar:

matplotlib.pyplot.bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs)
Make a bar plot.

Make a bar plot with rectangles bounded by:

left, left + width, bottom, bottom + height
(left, right, bottom and top edges)

However, "left" is in fact the center value of the resulting bars.

Code for reproduction

# Paste your code here
#
#
import numpy as np
import matplotlib.pyplot as plt
lefts = np.asarray((0, 100, 200, 300, 400))
plt.bar(left=lefts, height=lefts, width=100)
plt.bar(left=lefts, height=lefts, width=75)
plt.bar(left=lefts, height=lefts, width=50)
plt.bar(left=lefts, height=lefts, width=25)

Actual outcome
mwe-bar

# If applicable, paste the console output here
#
#

Expected outcome
Bars should be left-aligned to the "left" value.
As the attached plot shows: Bars are centered on "left" value, and not left-aligned to it.

Matplotlib version

  • Operating System: Fedora Linux 26
  • Matplotlib Version: 2.0.2
  • Python Version: 3.6
  • Jupyter Version (if applicable):
  • Other Libraries:

matplotlib installed using pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0