Skip to content

Inconsistency between documentation and actual effect of the bar plot function #8327

Closed
@jdhao

Description

@jdhao

Bug report

Bug summary

There is an inconsistency between the matplotlib's documentation and actual outcome of the bar plot function. The documentation says that left argument in the bar plot function indicate

the x coordinates of the left sides of the bars

In fact, the left parameter indicate the center of the bar.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np
N = 3
width = 1.0
stat = [2.4, 3.2, 1.6]
ind = np.arange(1, 6, 2, dtype=np.float32)

fig, ax = plt.subplots()
ax.bar(ind, stat, width )
ax.set_xticks(ind+width/2.0)
plt.show()

Actual outcome and expected outcome

The x axis ticks should be in the center of bar if the documentation is right. In fact, the ticks are in the right side of each bar. See figure below
image

Matplotlib version

  • Matplotlib version: 2.0.0
  • Python version: 2.7.13 and 3.5.2
  • Platform: Linux (CentOS 7) and Windows
  • How did you install Matplotlib and Python: Anaconda

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