Skip to content

Borders appear only for the first bar in the bar plot. #9820

Closed
@guziy

Description

@guziy

Bug report

Only the first bar in barplot has border when edgecolor is a single value.

Bug summary

Code for reproduction

import matplotlib.pyplot as plt


def main():

    fig = plt.figure()
    ax = plt.gca()

    data = list(range(5, 10))

    ax.bar(data, data, width=0.5, align="edge", linewidth=2,
           edgecolor="k", facecolor="m")

    plt.show()


if __name__ == '__main__':
    main()

Actual outcome
screen shot 2017-11-20 at 15 50 34

Expected outcome

screen shot 2017-11-20 at 15 51 51

I can work around the issue by specifying a list of edgecolors and linewidths for each bar. Specifying only the list of linewidths for each bar and leaving one value for the edgecolor would only show a border of the first bar due to this code in the Patch.draw:

        lw = self._linewidth
        if self._edgecolor[3] == 0:
            lw = 0

Matplotlib version

  • Operating system: Linux
  • Matplotlib version: 2.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: Python 3.6.2

I installed matplotlib using conda. But I am not sure from which channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions