-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Added example on how to make packed bubble charts #18223
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check and fix the flake8 comments in the "Files changed" tab.
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
examples/misc/packed_bubbles.py
Outdated
|
||
# collapse plot 50 times. In some cases it might be useful | ||
# to do this more or less often | ||
for i in range(50): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite following the loop here. What happens if you only do this once versus 50 times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each loop further packs the plot by moving the bubbles. (the bubbles move less each time fewer than 10% of bubbles could move without colliding.) The following pictures show the result when running the loop 0, 1, 10 or 50 times. When using 3000 bubbles, you might only want to run the loop 20 times, when you want to perfectly pack 4 Bubbles, you might run it 300 times.
0 loops
1 loop
10 loops
50 loops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems closely related to the algorithms behind kmeans cluster analysis. Is there anything to be borrowed from that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I came up with everything myself, but it can still have some similarities.
Co-authored-by: Jody Klymak <jklymak@gmail.com>
examples/misc/packed_bubbles.py
Outdated
@@ -0,0 +1,176 @@ | |||
""" | |||
Create a packed bubble / non overlapping bubble chart to represent scalar data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The section title has vanished again.
I assume this was not intentional. Please let us know if you need help with git/github workflow for updating pull requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get how I pull the changes I committed on github.com to my local repo. I did a pull but it seems like nothing arrived in my local repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What make it even weirder for me is the fact that the title disappeared in 7e1598d without showing up as diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually do git fetch origin
, and then in the branch git rebase origin/<branch-name>
. If I've worked locally on the branch there may be conflicts that need to be resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will approve after the two comments are addressed.
There could be some more polishing on the internal structure of BubbleChart
(The bubbles
array seems not quite a good storage structure. Having indices 0-3 for x, y radius and area is quite opaque.). But I've already triggered enough review rounds and don't want to ride the PR to death. It's good enough now, and further improvements can always be added later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not look too deeply at the algorithm, but noticed a few typos. Please also avoid shortening words in comments; I did not make note of all of them.
CI failure is a OSX issue and unrelated to this PR. |
Thanks @McToel! Congratulations on your first contribution to Matplotlib. We hope to see you back some time. |
Thank you for your time to review this PR! |
* Added example on how to make packed bubble charts * fixed style errors * Apply suggestions from code review Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Jody Klymak <jklymak@gmail.com> * applied rewiews * fixed typo * readded title * style fix * Apply suggestions from code review * removed blank line * nicer array casting * Apply suggestions from code review * fixed variable names in docstring Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Co-authored-by: Jody Klymak <jklymak@gmail.com>
PR Summary
Added example on how to make packed bubble charts
PR Checklist