我想要做的是从googleVis包中向R中的折线图添加一条垂直线。有没有人知道这是否受支持?例如,在下面的简单折线图中,我想在x=2处添加一条垂直线。这可能吗?
# Simple example. Must bring in 'googleVis' package first.
df <- data.frame(country=c(1,2,3), val1=c(1,3,4), val2=c(23,12,32))
Line1 <- gvisLineChart(df, xvar="country", yvar=c("val1", "val2"))
plot(Line1) 发布于 2014-03-19 03:58:46
通过询问开发人员,我意识到如何做到这一点。您可以使用NAs获得一条垂直参考线,如下所示:
library(googleVis)
dat <- data.frame(x=c(2,2,1,3,4),
y1=c(0,3,NA,NA,NA),
y2=c(NA,NA,0,3,2))
plot(gvisScatterChart(dat,
options=list(lineWidth=2,
pointSize=2))
)https://stackoverflow.com/questions/22432658
复制相似问题