2

我想创建一个ggvis有线条和一些点的情节。也就是说,我想在每条线上画三条线和一个点。我试过了:

data %>% 
    ggvis(x = ~x, y = ~value, stroke = ~variable) %>%
    group_by(variable) %>% layer_lines() %>% 
    layer_points(x = points[,1], y = points[,2])

其中 points 是一个数据框,其中包含我想要绘制的点,但这不起作用。

有任何想法吗?

谢谢

这是示例数据:

structure(list(x = c(0, 100, 200, 300, 400, 500, 600, 700, 800, 
900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 
2000), total = c(0, 12561.8501420367, 22436.5635024327, 31648.8752584019, 
39817.0210051915, 46555.4211041481, 51777.569893653, 56035.9877883034, 
59440.4188225383, 62168.6432420093, 64700.5282644047, 67507.9276458711, 
69915.0080895388, 71993.1498628426, 73801.8840967967, 75218.7298009381, 
76055.2047330129, 76752.2339780277, 77351.4962240531, 77893.1254687784, 
78434.7547135037)), .Names = c("x", "total"), row.names = c(NA, 
-21L), class = "data.frame")

以下是要点:

structure(list(V1 = c(46.3220011507472, 193.838339639222, 259.839658412055, 
499.999999202025), y = c(6040.39184354985, 16023.4572876059, 
26201.4660177994, 46555.4211041481)), .Names = c("V1", "y"), row.names = c("V1", 
"V2", "V3", "total_spend"), class = "data.frame")
4

0 回答 0