Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: Duplicating the labels in theheight/width argument inbarh()/bar leads to undrawn bars #29507

Closed
@JosephBARBIERDARNAL

Description

@JosephBARBIERDARNAL

Bug summary

When there are duplicate labels in my label array (for example:['first label', 'second label’, ‘third label', 'second label']),ax.bar() andax.barh() ignore the duplicates (both bars and labels).

Code for reproduction

importmatplotlib.pyplotaspltname= ["first label","second label","third label","second label",]value= [1,2,3,4]fig,ax=plt.subplots(layout="tight")ax.barh(name,value)foriinrange(len(name)):n=name[i]v=value[i]ax.text(x=v+1,y=i,s=f"{n} ({i})",va="center")

Actual outcome

Image

Expected outcome

A bar chart with 4 bars (the second ‘second label’ would be above the bar of the ‘third label’).

What's more, for some reason the bar on the ‘second label’ has a value of 4, whereas I was intuitively expecting it to have a value of 2?

Additional information

You might expect there to be only single labels, but as this isn't explained in the documentation, I've pointed it out just in case. It's quite hard to spot when you're drawing a lot of bars.

Operating system

MacOS Sonoma

Matplotlib Version

3.10.0

Matplotlib Backend

module://positron_ipykernel.matplotlib_backend

Python version

3.13.1

Jupyter version

/

Installation

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp