【问题标题】:Full opacity of fill colour填充颜​​色完全不透明
【发布时间】:2017-03-31 07:49:45
【问题描述】:

我想用 R 中的 Plotly 创建一个填充区域图。

可重现的例子:

library(plotly)
library(dplyr)

data <- data.frame(a = c("r","r","r","r","s","s","s","s"),
                   b = c(2,4,6,4,1,3,5,7),
                   c = c(1,2,3,4,1,2,3,4))
data %>% 
  plot_ly(x = ~c, y = ~b, split = ~a, type = 'scatter', mode = 'none', fill = 'tozeroy')

默认情况下,填充颜色的不透明度为 50%,但我希望它们具有 100% 的不透明度。 Plotly 提供了一个 opacity 和一个 alpha 参数,但它们都不影响填充颜色的不透明度。

我有什么想念的吗?

【问题讨论】:

    标签: r plotly


    【解决方案1】:

    也许你可以这样解决问题:

    data_r <- data[data$a == 'r',]
    data_s <- data[data$a == 's',]
    
    
    plot_ly(x = data_r$c, y = data_r$b, split = data_r$a, type = 'scatter', mode = 'none', fill = 'tozeroy', fillcolor = 'skyblue') %>%
      add_trace(x = data_s$c, y = data_s$b, split = data_s$a, type = 'scatter', mode = 'none', fill = 'tozeroy', fillcolor = 'coral')
    

    【讨论】:

      猜你喜欢
      • 2020-06-19
      • 1970-01-01
      • 2015-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-04
      • 2014-07-09
      相关资源
      最近更新 更多