Skip to content

VIS: NaN Handling in Pie Plots #8198

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

Closed
TomAugspurger opened this issue Sep 6, 2014 · 8 comments · Fixed by #8307
Closed

VIS: NaN Handling in Pie Plots #8198

TomAugspurger opened this issue Sep 6, 2014 · 8 comments · Fixed by #8307
Labels
API Design Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Visualization plotting
Milestone

Comments

@TomAugspurger
Copy link
Contributor

From #8177 (comment), how should we handle NaNs in Pie Plots. Right now the documented behavior is to fill 0s and plot. This can result in some unattractive labeling depending on where the NaNs are at in the series.

In [11]: series = Series(3 * np.random.rand(8), index=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], name='series')
In [15]: series.iloc[:4] = np.nan

In [16]: series.plot(kind='pie')
Out[16]: <matplotlib.axes._subplots.AxesSubplot at 0x11183e128>

nana

This is actually the first case where I can see a use for a NaN-handling kwarg in *.plot() itself. You could reasonably want to

  • Drop the NaNs (which I think should be the default)
  • Fill 0s (shows they're missing, but makes the labeling confusing)
  • Aggregate the NaNs and put those in a separate "missing" wedge that takes up some proportion of the pie.

I've got no idea how that proportion should be calculated (counts? relative to the sum or size?).

For now let's just decide if the default should change from filling 0s to filling dropping (with a couple releases of notice.)

cc @jorisvandenbossche @sinhrks

@TomAugspurger TomAugspurger added this to the 0.15.0 milestone Sep 6, 2014
@jorisvandenbossche
Copy link
Member

I would personally just change the default from filling with 0 to drop NA's

@sinhrks
Copy link
Member

sinhrks commented Sep 6, 2014

The reason filling by 0 is to associate same colors to index in subplot case. NA can be dropped with masking unnecessary colors.

@TomAugspurger
Copy link
Contributor Author

It may actually be better still fillna(0) so that they show up in the legend, but hide the labels so that it looks nicer.

@jorisvandenbossche
Copy link
Member

That sounds like a better idea, in any case the colors should of course stay the same.

@TomAugspurger
Copy link
Contributor Author

I've got a PR coming. Just need to push.

On Sep 12, 2014, at 2:13, Joris Van den Bossche [email protected] wrote:

That sounds like a better idea, in any case the colors should of course stay the same.


Reply to this email directly or view it on GitHub.

@jreback
Copy link
Contributor

jreback commented Oct 4, 2014

@TomAugspurger is this fixed? else can push

@TomAugspurger
Copy link
Contributor Author

This is done. Not sure why is wasn't closed.

@TomAugspurger
Copy link
Contributor Author

Fixed by #8307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants