`stat = "identity"` doesn't work if combined with `position='stack'`
See original GitHub issueI’ve noticed that even if I use the flag stat = "identity"
in a stacked bar plot, this doesn’t resolve and defaults to the "count"
option.
Here is an example of how you can replicate the issue:
import pandas as pd
from ggplot import *
import numpy as np
df = pd.DataFrame({'device': ['Computers', 'Computers', 'Mobile', 'Mobile', 'Tablets', 'Tablets'],
'conversion_type': ['conversions', 'cross-device', 'conversions', 'cross-device', 'conversions', 'cross-device'],
'revenue': list(np.random.normal(loc=5000, scale=1000, size=6))})
ggplot(df, aes(x='device', y='revenue', fill='conversion_type')) + \
geom_bar(stat='identity', position='stack')
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
ggplot position stack not adding values correctly
Here's a way to solve it, use position = "identity" : library(ggplot2) library(forcats) library(dplyr) gapminder::gapminder ...
Read more >how to combine position=stack and position=dodge in a single ...
Hi Hadley, I tried to replicate dodging in combination with stacking by facetting as you suggested. In principle this works, but identifying ...
Read more >`geom_bar` with `stat="identity"` and `position="stack"` broken if ...
When using geom_bar with already computed statistics and stacking them based on some ... and position="stack" broken if some fields missing #141. Open....
Read more >Bar charts — geom_bar • ggplot2
If you want the heights of the bars to represent values in the data, ... geom_bar( mapping = NULL, data = NULL, stat...
Read more >Chapter 3 Comparing distributions | Data Visualization ...
3.1.1 Position = stack/dodge/fill/identity ... This doesn't work, because when we are setting a particular feature, R expects a name of a colour, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m not sure how easy is to fix this, but if someone if willing to mentor me, I wouldn’t mind to contribute a fix. I’m not very familiar with the codebase though.
Same version of matplotlib, running everything in a jupyter notebook. However while trying to run it again, I got your result (all blue), and then when I killed and restarted my jupyter notebook a few times, sometimes I got my result (proper coloring) and sometimes your result (all blue). I have no idea what’s going on…