Reputation: 7735
Is there a way to remove the fill color from the ggplotly
legend since it is redundant with the facet? In other words, it's true that I essentially have four combinations, but I only want to show the levels of alpha in the legend because the faceting tells you the same information as the fill values. I don't need to explain what red and green mean since red only applies to facet group3==0
and green only applies to 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)
```
Upvotes: 1
Views: 1291
Reputation: 52708
I arrived here from google because a ggplot that didn't have a legend was being given one when ggplotly()
was called on it.
In case that affects anyone else, the answer is, use:
theme(legend.position='none')
as plotly understands that.
Upvotes: 2