Skip to content

doc: mention bar_label in bar and barh#31395

Open
turbotimon wants to merge 1 commit intomatplotlib:mainfrom
turbotimon:doc-mention-bar_label
Open

doc: mention bar_label in bar and barh#31395
turbotimon wants to merge 1 commit intomatplotlib:mainfrom
turbotimon:doc-mention-bar_label

Conversation

@turbotimon
Copy link

PR summary

Improves:

Minimal and previously missing information has been added on how to use bar_label to add labels to bars for bar and barh.

Motivation:

I was looking for this functionality, but couldn’t find any information about it in the documentation for bar or barh. Only an LLM was able to tell me that bar_label exists. I think this should be mentioned in these descriptions, since bar_label is specific to these functions.

** "Good first issue":**

Since this is my first contribution, let me know if something is missing or needs to be improved

AI Disclosure

No AI

PR checklist

@github-actions
Copy link

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.


label : str or list of str, optional
A single label is attached to the resulting `.BarContainer` as a
label for the whole dataset.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
legend label for the whole dataset.

In general, "label" on Artist is the legend label, but since we have legend labels and labels on the bars, it's better to be explicit here.

and will cause repeated label entries, so this is best used when
bars also differ in style (e.g., by passing a list to *color*.)
bars also differ in style (e.g., by passing a list to *color*).
Use `.bar_label` to add labels to bars.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still undecided whether. this addition is reasonable. On the one hand it's off-topic because here we are only concerned with the legend. On the other hand, it might be a reasonable cross-link.

If we do this I'd go with

Suggested change
Use `.bar_label` to add labels to bars.
Tip: Use `.bar_label` to place labels on the bars.

i.e. use more specific language "place on" instead of "add to"; move this to a separate paragraph and use the "Tip:" prefix to set it logically and visually apart. I've intentionally used plain-text Tip: and not an admonition, because an admonition would give this too much visual weight.

@melissawm melissawm moved this to Waiting for author in First Time Contributors Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Waiting for author

Development

Successfully merging this pull request may close these issues.

3 participants