8000 Added example on how to make packed bubble charts by McToel · Pull Request #18223 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 14 commits into from
Aug 16, 2020

Conversation

McToel
Copy link
Contributor
@McToel McToel commented Aug 11, 2020

PR Summary

Added example on how to make packed bubble charts

PR Checklist

Copy link
Member
@timhoffm timhoffm left a 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.

@jklymak jklymak added this to the v3.4.0 milestone Aug 12, 2020
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>

# collapse plot 50 times. In some cases it might be useful
# to do this more or less often
for i in range(50):
Copy link
Member

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?

Copy link
Contributor Author

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

0

1 loop

1

10 loops

10

50 loops

50

Copy link
Contributor
@dopplershift dopplershift Aug 12, 2020

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

Copy link
Contributor Author

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>
10000
@@ -0,0 +1,176 @@
"""
Create a packed bubble / non overlapping bubble chart to represent scalar data.
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member
@timhoffm timhoffm left a 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.

Copy link
Member
@QuLogic QuLogic left a 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.

@timhoffm timhoffm merged commit efa8bb0 into matplotlib:master Aug 16, 2020
@timhoffm
Copy link
Member

CI failure is a OSX issue and unrelated to this PR.

@timhoffm
Copy link
Member

Thanks @McToel! Congratulations on your first contribution to Matplotlib. We hope to see you back some time.

@McToel
Copy link
Contributor Author
McToel commented Aug 16, 2020

Thank you for your time to review this PR!

andrzejnovak pushed a commit to andrzejnovak/matplotlib that referenced this pull request Sep 9, 2020
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0