添加背景线到plotly

时间:2016-12-15 14:31:29

标签: r plotly

我有一个用R编写的绘图对象,我想在其上放置1:1预测精度线。这很棒!

plot_ly() %>%
  add_lines(x = c(1, 35), y = c(1, 35), showlegend = FALSE) %>%
  add_trace(data = mtcars, x = ~mpg, y = ~mpg + rnorm(32, 0, 3), color = ~factor(cyl),
            mode = "markers", type = "scatter")

first plot

除了线路有点重。不幸的是,如果我试图改变它的视觉外观,它会与我的另一层中的美学混淆。

plot_ly() %>%
  add_lines(x = c(1, 35), y = c(1, 35), showlegend = FALSE,
            color = "grey", alpha = 0.8) %>%
  add_trace(data = mtcars, x = ~mpg, y = ~mpg + rnorm(32, 0, 3), color = ~factor(cyl),
            mode = "markers", type = "scatter")

## Warning messages:
## 1: In colScale(as.character(color[[i]])) :
##   Some values were outside the color scale and will be treated as NA
## 2: In colScale(as.character(color[[i]])) :
##   Some values were outside the color scale and will be treated as NA
## 3: In colScale(as.character(color[[i]])) :
##   Some values were outside the color scale and will be treated as NA

trying to make it grey

我有什么东西在这里失踪吗?即,一种将美学与每一层隔离的方法?

0 个答案:

没有答案