FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[MNT]: Is broken_barh redundant? · Issue #24827 · matplotlib/matplotlib · GitHub

Repository navigation

[MNT]: Is broken_barh redundant? #24827

Closed

Description

Summary

broken_barh() documentation does not mention barh() but they seem very similar. I'm able to replace calls to broken_barh() with a call to this:

def broken_barh_using_barh(ax, xranges, yrange, **kwargs):
    kwargs2={'align':'edge'} 
    for k,v in kwargs.items():
        if k == 'facecolors':
            kwargs2['color'] = v
        else:
            kwargs2[k] = v
    ax.barh(y=yrange[0], height=yrange[1], left=[x[0] for x in xranges], width=[x[1] for x in xranges], **kwargs2)

So is there something that broken_barh() offers that barh() doesn't?

Proposed fix

It would help to document the difference if there is a meaningful one, otherwise perhaps deprecate broken_barh().

Activity

  1. timhoffm commented on Sep 19, 2024

    Member

    They serve different semantic use cases:

    • barh() is a regular horizontal bar plot. I.e. multiple bars stacked vertically side-by side (i.e. in y-direction).
    • broken_barh() is a seqence of bars / rectangles arranged (with possible spaces) horizontally (i.e. in x-direction).
      This kind of visualization is not too common but for example used to illustrate events / durations when x is time.

    You can draw one through a sequence of calls through the other. As you could with fill() or Rectangle()`, but their interfaces (and implementation are optimized for the specific use case.

    I don't see what to document additionally here they are just two semantically different plotting functions that happen to both draw rectangles. Somebody with the one use case would not come to the idea to use the other function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL