Need help with the aligning of the labels on the barplot.
Here is the reproducible code:
library(ggmap)
library(ggplot2)
library(gganimate)
library(r
With recent updates to ggplot2
, you can do this by setting position = position_stack(vjust = 0.5)
in geom_text()
.
It may also interest you that you can use geom_col()
as a shortcut for geom_bar(stat = "identity")
. Also, labs
has a title and subtitle parameter, so you don't need to use it and ggtitle
.
ggplot(data = mydf1, aes(x = year, y = channels, fill = type, frame = year, cumulative = TRUE)) +
geom_col() +
labs(x = "year", y = "y", title = "Data Here", subtitle = "Statistics") +
geom_text(aes(label = channels), color = "white", size = 3, position = position_stack(vjust = 0.5)) +
theme_minimal()