我正在尝试生成一个 ggplot 图并且很难让轴正确。我希望将它们从 ggplot 最初给出的范围扩大。这是我的数据:
Date <- c("07/12/2012 05:00:00", "07/12/2012 06:00:00", "07/12/2012 07:00:00",
"07/12/2012 08:00:00","07/12/2012 10:00:00","07/12/2012 11:00:00")
Date <- strptime(Date, "%d/%m/%Y %H:%M")
Counts <- c("0","3","10","6","5","4")
Counts <- as.numeric(Counts)
df1 <- data.frame(Date,Counts,stringsAsFactors = FALSE)
library(ggplot2)
g = ggplot(df1, aes(x=Date, y=Counts)) + geom_line(aes(group = 1))
g + scale_y_continuous(limits = c(0, 15))
g + scale_x_continuous(limits = c(04:00, 13:00))
g
我认为问题在于连续数据与离散数据(特别是如何处理 Date 变量),但我正在努力修复代码。任何帮助将不胜感激。