【问题标题】:Transparent background with ggplotly in R not possible?不可能在 R 中使用 ggplotly 的透明背景?
【发布时间】:2021-03-18 13:37:06
【问题描述】:

这是我的主题

theme(
    text = element_text(size = 14, color = "white"),
    axis.text = element_text(size = 10, color = "white", face = "bold"),
    axis.text.y =element_blank(),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    plot.background = element_rect(fill = "transparent",colour = NA),
    axis.line.x = element_blank(),
    axis.title.x =       element_blank(),
    axis.title.y =       element_blank(),
    panel.background =   element_rect(fill = "transparent",colour = NA),
    plot.margin =        unit(c(1, 1, 1, 1), "lines"),
    legend.text =        element_text(size = 10, 
                                      color = "white",
                                      face = "bold",
                                      margin = margin(l = 0.25, unit = "cm")
                                      ),
    legend.title =       element_blank(),
    legend.background =   element_rect(fill = "transparent",colour = NA)
  )

    ggplotly(plot)

一切都按预期工作,我可以使用所有颜色,但是当我将背景设置为透明时,结果是白色背景。 ggplotly 不接受透明背景吗?

【问题讨论】:

  • 如果添加legend.box.background = element_rect(fill = "transparent") 和legend.key = element_rect(fill = "transparent", color = NA),
  • 没有用。还是白的。

标签: r ggplot2 ggplotly


【解决方案1】:

如果你用透明替换它是否有效

"#RRGGBBAA"

(来自https://ggplot2.tidyverse.org/reference/aes_colour_fill_alpha.html

您是否导出了您的绘图以检查透明度?

【讨论】:

  • 我在尝试此操作时收到以下错误消息:“'color' or 'lty' 中的十六进制数字无效”
猜你喜欢
  • 2011-07-28
  • 1970-01-01
  • 1970-01-01
  • 2020-11-07
  • 1970-01-01
  • 2012-02-01
  • 1970-01-01
  • 2011-12-15
  • 1970-01-01
相关资源
最近更新 更多