Closed sda030 closed 5 years ago
Thanks @sda030. Stacked positions is definitely on the future additions list, as soon as I can figure out how to do it properly.
@sda030 I've just pushed a dev version with support for position = "stack"
. To do this I had to change width and height from aesthetics to arguments, which is probably an improvement anyway. You'll still need to manually adjust the height/width to fit the bar. You can install the dev version with `devtools::install_github("wilkox/ggfittext").
breakdown <- data.frame(sector = rep("fast food", 4),
firm = c("McDonalds", "KFC", "Hungry Jacks", "Subway"),
share = c(40, 20, 8, 32))
ggplot(breakdown, aes(x = sector, y = share, fill = firm, label = firm)) +
geom_bar(position = "stack", stat = "identity") +
geom_fit_text(position = "stack", grow = T) +
coord_flip()
Please give it a try and let me know how it works for you!
Tried out a few ways and works well! (Sorry late reply)
Hi, nifty package. Would it be possible to implement a feature for the labels (typically percentages) that could be printed on top of a stacked bar graph? Or at least hide those which won't fit? I am currently using
geom_col(position = "fill") + geom_text(aes(label = sprintf(prop*100, fmt="%1.0f%%")), position = position_stack(vjust = 0.5), size=3)