DOC: Refactor code in the fishbone diagram example#28144
Merged
timhoffm merged 1 commit intomatplotlib:mainfrom May 2, 2024
Merged
DOC: Refactor code in the fishbone diagram example#28144timhoffm merged 1 commit intomatplotlib:mainfrom
timhoffm merged 1 commit intomatplotlib:mainfrom
Conversation
0782ed6 to
47f9ae1
Compare
timhoffm
reviewed
Apr 27, 2024
47f9ae1 to
f748ddb
Compare
timhoffm
reviewed
Apr 29, 2024
|
|
||
| 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]] |
Member
There was a problem hiding this comment.
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.
Member
There was a problem hiding this comment.
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 of spine_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)
| # 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) |
Member
There was a problem hiding this comment.
Suggested change
| draw_spine(spine_length, head_pos, tail_pos) |
timhoffm
approved these changes
May 2, 2024
meeseeksmachine
pushed a commit
to meeseeksmachine/matplotlib
that referenced
this pull request
May 2, 2024
timhoffm
added a commit
that referenced
this pull request
May 2, 2024
…144-on-v3.9.x Backport PR #28144 on branch v3.9.x (DOC: Refactor code in the fishbone diagram example)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
causeanddraw_bodyfunctions.draw_spinecode fromdraw_bodyand turn into its own function.