Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Stacked bar plot negative values do not work correctly if dataframe contains NaN values #8175
Comments
|
cc @sinhrks. Thanks for the report. |
TomAugspurger
added Bug Visualization Missing-data
labels
Sep 4, 2014
TomAugspurger
added this to the
0.15.0
milestone
Sep 4, 2014
|
No problems, glad to help. On Thu, Sep 4, 2014 at 2:13 PM, Tom Augspurger notifications@github.com
|
TomAugspurger
closed this
in #8177
Sep 7, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tom-alcorn commentedSep 4, 2014
While trying to produce a stacked bar plot which includes negative values, I found that if the dataframe contains NaN values the bar plot does not display correctly.
Specifically, this code:
incorrectly produces this plot
Notice that at '2' on the x-axis, there should be a bar of size -10 for each of the 'B' and 'C' categories.
However, when I replace the NaN values with 0s by doing
then the plot displays correctly
This is clearly not a good behaviour. I suspect that this happens because the bars corresponding to the negative values are trying to use np.nan as their 'bottom' argument and thus not displaying at all, but I haven't investigated further.
It would be nice if area-style plots like this would either automatically replace NaN values with 0 or throw an error about NaN values present in the dataframe causing problems for the plotting functions.