My data:
day variable value
1 Fri avg1 446.521127
2 Mon avg1 461.676056
3 Sat avg1 393.366197
4 Sun avg1 435.985714
5 Thu avg1 445.571429
6 Tue avg1 441.549296
7 Wed avg1 462.042254
8 Fri avg2 7.442113
9 Mon avg2 7.694648
10 Sat avg2 6.556056
11 Sun avg2 7.266571
12 Thu avg2 7.426286
13 Tue avg2 7.359577
14 Wed avg2 7.700282
My issue is I want to create a bar graph using facet_grid
displaying each set of avg data by day, but the observations are similar enough that I've found it helpful to specify the y-limits using scale_y_continuous
.
So, if I assign my ggplot to g <- ggplot(df, aes(x=day, y=value))
, I can get half of what I want by each of:
g + geom_bar(stat="identity") + facet_grid(variable~., scales="free")
AND
g + geom_bar(stat="identity") + scale_y_continuous(limits=c(300,500), oob=rescale_none)
However, I don't know how to use facet grid and then specify a scale_y_cont that will limit the size of separate y-axes. Is there a solution?
See Question&Answers more detail:os