I have a bar plot in ggplot. When I set limits for the y axis I get an empty plot, as if the frame I set was outside of the data. I have tried both scale_y_continuous and the shorthand ylim.
The initial plot, which creates a meaningful graph:
p <- ggplot(data=subset(df), aes(x=Date, y=Time, fill=Total)) +
geom_bar(stat="identity") +
scale_y_continuous(breaks=c(8,10,12,14,16,18),
labels=c("8 am", "10 am", "12 pm", "2 pm", "4 pm", "6 pm"))`
The structure of df:
'data.frame': 25 obs. of 3 variables:
$ Date : Date, format: "2015-07-20" "2015-07-21" "2015-07-22" ...
$ Time : num 11.24 10.3 10.51 9.64 12.9 ...
$ Total: int 7 9 9 4 6 1 6 7 6 10 ...
Plot with limits, which produces an empty frame:
p <- ggplot(data=subset(df), aes(x=Date, y=Time, fill=Total)) +
geom_bar(stat="identity") +
scale_y_continuous(breaks=c(8,10,12,14,16,18),
labels=c("8 am", "10 am", "12 pm", "2 pm", "4 pm", "6 pm"),
limits=(c(7,18)`
Any ideas why adding limits loses the data? I don't ever receive an error.