繁体   English   中英

从 ggplotly 图例中删除填充颜色级别

[英]remove fill color levels from a ggplotly legend

有没有办法从ggplotly图例中删除填充颜色,因为它与刻面是多余的? 换句话说,我确实有四种组合,但我只想在图例中显示 alpha 的级别,因为分面告诉您与填充值相同的信息。 我不需要解释红色和绿色的含义,因为红色只适用于 facet group3==0而绿色只适用于 facet group3==1

在此处输入图片说明

---
title: "Example"
runtime: shiny
output:
  flexdashboard::flex_dashboard:
    vertical_layout: fill
---

```{r}
  library(tidyverse)
  library(plotly)
  library(flexdashboard)
```


### Chart 1

```{r}
  f <- list(family = "Poppins")
  a <- list(tickfont = f)

  p <- fortify(forecast::gold) %>%
       mutate(group1 = sample(0:1, n(), replace=TRUE),
              group2 = sample(0:1, n(), replace=TRUE),
              group3 = sample(0:1, n(), replace=TRUE)
              ) %>%
    ggplot(., aes(factor(group1), y, alpha=factor(group2), fill=factor(group3))) + 
         geom_col() + 
         scale_alpha_manual(values = c(.5, 1)) +
         facet_wrap(~group3)

  ggplotly(p)
```

我从谷歌来到这里是因为当ggplotly()时,给出了一个没有图例的ggplotly()

如果影响其他人,答案是,使用:

theme(legend.position='none')

正如情节理解的那样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM