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: Refactor code in the fishbone diagram example#28144

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
timhoffm merged 1 commit intomatplotlib:mainfromsaranti:refactor_fishbone
May 2, 2024

Conversation

saranti
Copy link
Contributor

PR summary

  • Simplify the code in thecause anddraw_body functions.
  • Remove thedraw_spine code fromdraw_body and turn into its own function.
    • Fixed issue where the spine was being rendered multiple times due to being inside a loop.
  • Improve docstrings and comments.
  • Other minor changes.

@github-actionsgithub-actionsbot added the Documentation: examplesfiles in galleries/examples labelApr 27, 2024
@sarantisarantiforce-pushed therefactor_fishbone branch 2 times, most recently from0782ed6 to47f9ae1CompareApril 27, 2024 06:18

spine_length = [-2.1 - length, 2 + length]
head_pos = [2 + length, 0]
tail_pos = [[-2.8 - length, 0.8], [-2.8 - length, -0.8], [-2.0 - length, -0.01]]
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
tail_pos= [[-2.8-length,0.8], [-2.8-length,-0.8], [-2.0-length,-0.01]]
tail_pos= [[-2.8-length,0.8], [-2.8-length,-0.8], [-2.0-length,-0.01]]
draw_spine(spine_length,head_pos,tail_pos)

Let's move drawing the spine up here, this is where all relevant input for the function is calculated. Also, it's the order , you would draw such a diagram by hand: first the spine, and then the problem categories.

saranti reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

It may even be a good idea to pull all the positioning details in to the function, so that you do

draw_spine(-2 - length, 2 + length)

which gives the length of the line.

Note that the left ofspine_length is -0.1 compared to that, which I assume is so that the line reaches into the tail triangle. Otherwise the transition may not look smooth. But that should be an implementation detail, i.e. (or so - untested)

def draw_spine(xmin, xmax):    ...    # draw main spine    ax.plot([xmin-0.1, xmax], [0, 0], color='tab:blue', linewidth=2)    # draw fish head    ax.text(xmax + 0.1, - 0.05, 'PROBLEM', fontsize=10,            weight='bold', color='white')    semicircle = Wedge((xmax, 0), 1, 270, 90, fc='tab:blue')    ax.add_patch(semicircle)    # draw fishtail    tail_pos = [[xmin - 0.8, 0.8], [xmin - 0.8, -0.8], [xmin, -0.01]]    triangle = Polygon(tail, fc='tab:blue')    ax.add_patch(triangle)

saranti reacted with thumbs up emoji
# the cause_arrow_x, cause_arrow_y coordinates.
causes(problem, cause_arrow_x, cause_arrow_y, top=top_row)
causes(problem, cause_arrow_x, cause_arrow_y, top=plot_above)
draw_spine(spine_length, head_pos, tail_pos)
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
draw_spine(spine_length, head_pos, tail_pos)

saranti reacted with thumbs up emoji
@timhoffmtimhoffm added this to thev3.9.1 milestoneMay 2, 2024
@timhoffmtimhoffm merged commite253aa2 intomatplotlib:mainMay 2, 2024
22 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestMay 2, 2024
timhoffm added a commit that referenced this pull requestMay 2, 2024
…144-on-v3.9.xBackport PR#28144 on branch v3.9.x (DOC: Refactor code in the fishbone diagram example)
@sarantisaranti deleted the refactor_fishbone branchMay 3, 2024 00:13
@QuLogicQuLogic modified the milestones:v3.9.1,v3.9.0May 3, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm approved these changes

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

Successfully merging this pull request may close these issues.

3 participants
@saranti@timhoffm@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp