Reputation: 135
I want to display time series data on a grouped bar chart. I filtered the two variables from one column (x, y). Unfortunately I can't figure out how to display them grouped.
Using the code below will stack the bars:
library(ggplot2)
library(dplyr)
target <- c("x", "y")
filtered_dat <- filter(dat, column %in% target)
ggplot(filtered_dat, aes(year, column)) +
geom_col(position = "dodge", stat = "identity", width = 0.7) +
geom_text(aes(label = column), colour = "white")
Thank you very much for any help.
Upvotes: 0
Views: 137
Reputation: 135
The group aes()
solves the problem. Therefore I had to group them with the group = column
code.
Upvotes: 0