Skip to content

Navigation Menu

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

Appearance settings

bar_label clipping #19429

Copy link
Copy link
Open
Open
Copy link
@anntzer

Description

@anntzer
Issue body actions

Bug report

Bug summary

bar_label currently uses the default annotation() clipping behavior, which is to draw the text unclipped as long as the annotated point is within the axes. I'm not sure this is the best behavior for this use case?

Code for reproduction

from pylab import *

ax = gca()
rs = ax.bar(np.arange(50), np.arange(50))
ax.bar_label(rs)
ax.set(ylim=(0, 40))
show()

Actual outcome

test

Note how the 39 and 40 labels are still drawn (effectively, because the bar tops are within axes limits), but not the subsequent ones.

Expected outcome

I'm not sure what the best behavior would be, but it should likely be one of the following:

  • perform "normal" clipping (so 39 is half-clipped, 40 is fully clipped out)
  • don't draw any labels that would be clipped (39 is hidden)
  • don't clip at all (all labels are visible)

bar_label is new in 3.4 so it may be worth deciding on this before the 3.4 release.

Matplotlib version

  • Operating system: linux
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): head
  • Matplotlib backend (print(matplotlib.get_backend())): agg
  • Python version: 39
  • Jupyter version (if applicable):
  • Other libraries:

(inspired by #19428, but that bug report is using a pre-bar_label labeling approach.)

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.