1

バグのプロットに別のdata.frameにあるリリース日で注釈を付けたいのですが、vlineの色を対応する元のトレースの色と一致させたいです

# first create some dummy data
set.seed(123)
N <- 100
adf <- data.frame(version=sample(c('A','B','C'), N, replace=TRUE),
              cs=as.POSIXct('2011-06-01 00:00') + rnorm(N, 20, 70)*86400)
# lets just shift things slightly, depending on version
adf$cs <- adf$cs + (as.integer(adf$version) - 1)*5e6
adf <- adf[order(adf$cs),]
library(plyr)
adf <- ddply(adf, .(version), function(bdf) { cbind(bdf, bugno=1:nrow(bdf)) } )

# now lets plot these bug curves by version
library(ggplot2)
q <- qplot(cs, bugno, data=adf, geom='line', colour=version,
  xlab='', ylab='Number of Bugs')
print(q)

# however I'd like to annotate these plots by adding the 
# dates of "release", with the colour matching that of release 
# in the plot q, so no further annotation necessary (hopefully!)
g.res <- data.frame(version=c('A','B','C'),
                releasedate=c(as.Date('2011-06-01'), as.Date('2011-10-01'),
                              as.Date('2012-01-01')))
# works... but only in blue...
q + geom_vline(data=g.res, aes(xintercept=as.POSIXct(releasedate)), col="blue") 

ggplot2チャートの毎日正午にAxisが中断することと、垂直geom_vlineをクラス日付のx軸に取得する方法を知っていますか?

4

1 に答える 1

1

そして、私はこのすべての作業を質問に入れたので、私はちょうど答えに気づきました...色はaesの一部でなければなりません!私はまだaesがどのように機能するかについて適切な理解を持っていません、私は本をもう一度読まなければなりません!:-)

q + geom_vline(data=g.res, aes(xintercept=as.POSIXct(releasedate), col=version) )
于 2012-06-17T10:57:00.983 に答える