8000 [MNT]: Is broken_barh redundant? · Issue #24827 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

[MNT]: Is broken_barh redundant? #24827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
omasoud opened this issue Dec 27, 2022 · 1 comment
Closed

[MNT]: Is broken_barh redundant? #24827

omasoud opened this issue Dec 27, 2022 · 1 comment

Comments

@omasoud
Copy link
omasoud commented Dec 27, 2022

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().

@timhoffm
Copy link
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
Projects
None yet
Development

No branches or pull requests

2 participants
0