Plotting negative and positive contributions in stacked bar plot independently #3809
Unanswered
FabianHofmann
asked this question in
Q&A
Replies: 2 comments 4 replies
-
It's a little unclear what you're trying to do here. Can you show an example using one of the built-in datasets? |
Beta Was this translation helpful? Give feedback.
2 replies
-
Unfortunately no, for the previous example it seems to work fine, but when having multiple negatives and positives, they do not stack on top. import pandas as pd
import seaborn.objects as so
df = pd.DataFrame(
{
"node": ["node1", "node1", "node1", "node2", "node2", "node2"],
"carrier": ["H2", "AC", "DC", "H2", "AC", "DC"],
"value": [1, -2, -3, 3, -4, 2],
}
)
plot = so.Plot(df, x="node", y="value", color="carrier")
plot = plot.add(so.Bar())
plot yields whereas I would wish to have all negative segments added on top each on the negative side and all positives on the positive side. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the object interface API, I am struggling to find a good approach on plotting stacked bar plots from positive and negative values at the same time. As far as I see, all contributions add on top of each other. This means that if a negative value follows a positive, it will start from the end point of the positive, resulting in automatic overlapping.
Is there a possible way to disable overlapping of contributions in stacked bar plots? Like this negative values would always stack on the negative side, positives values on the positive side.
Many thanks for the great package!
Beta Was this translation helpful? Give feedback.
All reactions