this is my dataframe:
mydf <- structure(list(NOME = c(1, 1, 1, 1, 1), PLAYER.POSITION = c("Lateral",
"Lateral", "Lateral", "Lateral", "Lateral"), variables_bar = structure(5:1, .Label = c("ACCELERATIONS.Z6",
"ACCELERATIONS.Z5", "ACCELERATIONS.Z4", "ACCELERATIONS.Z3", "ACCELERATIONS"
), class = "factor"), value = c(185L, 111L, 49L, 22L, 3L)), row.names = c(NA,
-5L), class = c("tbl_df", "tbl", "data.frame"))
This is my plot:
mydf %>% ggplot() geom_col(aes(x = NOME, y = value, fill = variables_bar)) geom_label(aes(x = NOME, y = value,label = value))
The labels should be on the top of each bar, but its not.
Any help ?
CodePudding user response:
Here is one way we could do it:
library(tidyverse)
mydf %>% ggplot()
geom_col(aes(x = NOME, y = value, fill = variables_bar))
geom_label(aes(x = NOME, y = value, label = value),size=5,
position=position_stack(vjust=0.5))