X Tutup
Skip to content

nested pie example#8546

Merged
phobson merged 1 commit intomatplotlib:masterfrom
choldgraf:nested_pie
Apr 28, 2017
Merged

nested pie example#8546
phobson merged 1 commit intomatplotlib:masterfrom
choldgraf:nested_pie

Conversation

@choldgraf
Copy link
Copy Markdown
Contributor

This adds the nested pyplot examples that were demoed in the gitter by @phobson and @anntzer. Both were cool, and since it was in response to a user asking how to create this, I assume that there are many other users that would like to know how to do this but didn't think to ask on the gitter, thus the example!

The following examples show how two ways to build a nested pie chart
in Matplotlib.

The most straightforward way to build a pie chart is to use the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would make this part a comment (instead of a docstring) for symmetry with below.

}
outer['height'] = np.zeros_like(outer['left']) + 3

ax.bar(**inner, **common_opts)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Too modern syntax (I know it's sad we don't get to use it).

###############################################################################
# However, you can accomplish the same output by using a bar plot on
# axes with a polar coordinate system. This may give more flexibility on
# the exact design of the plot.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the two examples should show the same data (if not necessarily the same style). For the one below, that probably means calling something like np.histogram(data, cumulative=True) * 2 * np.pi and fiddling with partial sums.

@choldgraf
Copy link
Copy Markdown
Contributor Author

@anntzer first two comments addressed, for the last comment I added more explanation to the rST explaining what kinds of inputs each approach takes. That seemed like a more straightforward solution than trying to do some kind of mapping between the original bins and 2*pi...the point of the example is just to show the visuals anyway. LMK if that works

@anntzer
Copy link
Copy Markdown
Contributor

anntzer commented Apr 28, 2017

Sure.

@choldgraf
Copy link
Copy Markdown
Contributor Author

(travis failure is the infamous ImageComparisonFailure)

@WeatherGod
Copy link
Copy Markdown
Member

Restarted the failed test.

@choldgraf
Copy link
Copy Markdown
Contributor Author

looks like all are passing now

@anntzer anntzer changed the title nested pie example [MRG+1] nested pie example Apr 28, 2017
@phobson phobson merged commit 69ef954 into matplotlib:master Apr 28, 2017
@QuLogic QuLogic changed the title [MRG+1] nested pie example nested pie example Apr 28, 2017
@QuLogic QuLogic added this to the 2.1 (next point release) milestone Apr 28, 2017
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.

5 participants

X Tutup