我想在同一图上有多个“线”。多个数据点。R脚本,ggplot2和qplot,同一图上的多个时间序列线图
在我的例子中,如何包含'xa'和'xb'数据点。
这就是我只有一组数据点,但我想要两个。我怎样才能修改这个脚本。
library(ggplot2)
da <- c("2012-02-02 09:01:00", "2012-02-02 09:02:00", "2012-02-02 09:03:00")
db <- c(0.4, 0.6, 0.5)
xa <- c("2012-02-02 09:01:00", "2012-02-02 09:02:00", "2012-02-02 09:03:00")
xb <- c(0.3, 0.43, 0.7)
da2 <- as.POSIXct(da)
dfx <- data.frame(da2, db)
summary(dfx)
png('time_data_errs6b.png', width=640, height=480)
gg <- qplot(da2, db, colour='red')+
opts(title = 'Requests App')+xlab('Time')+ylab('Requests') +
geom_line()
print(gg)
dev.off()
观察结果:'gg < - qplot(...)'语句现在(2015年6月; R版本3.1.1)生成'错误:使用'主题'。 (Defunct;最后在版本0.9.1中使用)'。错误指的是使用'opts(title ='Requests App')'。看起来,直接替换'opts'(在这个上下文中)是'labs(title ='Requests App')',可以选择修改主题,如theme(plot.title = element_text(size = rel(2) ,color =“blue”))'。 – 2015-06-19 22:23:45