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

DOC: Update broken_barh example#29488

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
story645 merged 1 commit intomatplotlib:mainfromtimhoffm:example-broken_barh
Jan 22, 2025

Conversation

timhoffm
Copy link
Member

IMHO this is more realistic and better looking.

I've always been wondering what the previous plot should mean.

@github-actionsgithub-actionsbot added the Documentation: examplesfiles in galleries/examples labelJan 20, 2025
@timhoffmtimhoffmforce-pushed theexample-broken_barh branch 2 times, most recently fromcae42c4 to92aa1a3CompareJanuary 20, 2025 11:55
arrowprops=dict(facecolor='black', shrink=0.05),
fontsize=16,
horizontalalignment='right', verticalalignment='top')
ax.broken_barh(cpu_1, (5.8, 0.4))
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
ax.broken_barh(cpu_1, (5.8,0.4))
# xranges, yrange
ax.broken_barh(cpu_1, (5.8,0.4))

yes it's shown in the image, but it's an easy reference point here

Copy link
MemberAuthor

@timhoffmtimhoffmJan 22, 2025
edited
Loading

Choose a reason for hiding this comment

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

Thanks for the suggestion. After thinking about it, I've decided against adding such information for the following reaons:

In the suggested form, I feel it's not obvious thatxranges, yrange map tocpu_1, (5.8, 0.4)) in the line below. This is because (1) it's not clear that the comment refers to the the args of the function and (2) the structural mapping is difficult, because yrange is spelled out in a tuple and is explicit numeric values, whereas xranges is given as a named variable.

Discarded alternatives:

  • # broken_barh(xranges, yrange): Even then, the meaning of the yrange tuple is a bit mysterious and readers would have to look up the definition. (On a side node, I'd have expected either (ymin, ymax) or (ycenter, height), but not (ymin, height)).
  • # broken_barh(xranges, (ymin, height)): That would be okish, OTOH it feels a bit stupid if we have to repeat the signature as a comment.
  • a kwargbroken_barh(cpu_1, yrange=(5.8, 0.4)): While this is instructive, I don't think people would typically use this in real applications.
  • a dedicated discussion of the API in the introduction: This feels a bit heavy.

I suppose, I'm stuggling with the API. The relevant (semantic) data are the xranges. The yrange is more or less a visual detail and should not deserve so much attention. IMHO this is a bit of a design flaw, but not solvable in the example. Therefore, I've resorted to writing the example like I would as real-world code, and leave it up to the user to look up the exact API.

Copy link
Member

@story645story645Jan 22, 2025
edited
Loading

Choose a reason for hiding this comment

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

# broken_barh(xranges, (ymin, height))

I understand why you feel like it's a hack but I think signature as comment is appropriate here b/c I'm hoping it reduces the cognitive load of parsing the example by explaining what those second (feel kinda arbitrary) numbers are.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Done. Not really convinced, but it's not worth fighting over.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

IMHO this is more realistic and better looking.I've always been wondering what the previous plot should mean.Note: There's precedence for a similar special-casing on polar Axes for errorbars:https://github.com/matplotlib/matplotlib/blob/3fb9c0961b5c8d5753c88ac37c08cda58a4b7839/lib/matplotlib/axes/_axes.py#L3798
@story645story645 added this to thev3.10.0-doc milestoneJan 22, 2025
@story645story645 merged commit597af1c intomatplotlib:mainJan 22, 2025
22 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestJan 22, 2025
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestJan 22, 2025
QuLogic added a commit that referenced this pull requestJan 22, 2025
…488-on-v3.10.xBackport PR#29488 on branch v3.10.x (DOC: Update broken_barh example)
timhoffm added a commit that referenced this pull requestJan 22, 2025
…488-on-v3.10.0-docBackport PR#29488 on branch v3.10.0-doc (DOC: Update broken_barh example)
timhoffm added a commit to timhoffm/matplotlib that referenced this pull requestJan 29, 2025
Follow-up tomatplotlib#29488.It's simpler to count upwards and use `invert_yaxis()` to ordertop-to-bottom rather than counting backwards
timhoffm added a commit to timhoffm/matplotlib that referenced this pull requestJan 29, 2025
Follow-up tomatplotlib#29488.It's simpler to count upwards and use `invert_yaxis()` to ordertop-to-bottom rather than counting backwards
@ksundenksunden mentioned this pull requestMar 3, 2025
5 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@story645story645story645 approved these changes

Assignees
No one assigned
Labels
Documentation: examplesfiles in galleries/examples
Projects
None yet
Milestone
v3.10-doc
Development

Successfully merging this pull request may close these issues.

2 participants
@timhoffm@story645

[8]ページ先頭

©2009-2025 Movatter.jp