Closed
Description
The placement of geom_text in the middle of a stacked bar_plot is off. When I run the example from the help file of geom_text
I get:
df <- data.frame(
x = factor(c(1, 1, 2, 2)),
y = c(1, 3, 2, 1),
grp = c("a", "b", "a", "b")
)
df <- transform(df, mid_y = ave(df$y, df$x, FUN = function(val) cumsum(val) - (0.5 * val)))
ggplot(data = df, aes(x, y, fill = grp, label = y)) +
geom_col() +
geom_text(aes(y = mid_y))
I suppose this is due to "position_stack()
and position_fill()
now stack values in the reverse order of the grouping, which makes the default stack order match the legend."
Metadata
Metadata
Assignees
Labels
No labels