I have the dataset with values for different keys for three independent groups and I would like to create a bar plot with these values for 3 different groups using facet_grid
. This is what I did so far, however I can not find the way to fix spacing between the bars (it is clearly observed form the picture that they are different). I tried changing arguments width
and position
for geom_col
, but it did not help. How can I fix it?
library(ggplot2)
# Loading
groups = c(rep("q", 8), rep("w", 8), rep("e", 8))
keys = c(c(1:8), c(1:8), c(1:8))
values = c(rep(8, 8), rep(8, 8), rep(8, 8))
data = data.frame(groups, values, keys)
ggplot(data, aes(x = keys, y = values)) +
geom_col(width=0.9375) +
facet_grid(~groups)