You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(ggplot2)
library(plotly)
library(viridis)
# If you want to draw arbitrary rectangles, use geom_tile() or geom_rect()
df <- data.frame(
x = rep(c(2, 5, 7, 9, 12), 2),
y = rep(c(1, 2), each = 5),
z = rep(c(1:4, NA), each = 2)
)
p <- ggplot(df, aes(x, y)) +
geom_tile(aes(fill = z)) +
scale_fill_gradientn(
colors = viridis(256),
na.value = "red")
p
ggplotly(p)
This issue could probably be renamed to a more general "ggplotly ignores na.value colour" as it applies also to other functions, like scale_fill_continuous() or scale_fill_gradient().
Here is a minimal reproducible example:
library(ggplot2)
library(plotly)
# default NA colour is "grey50"
(default_na_colour<- ggplot(mapping= aes(x=1:2, y=1:2, fill= c(1, NA))) +
geom_tile())
talgalili
changed the title
Bug: ggplotly ignores na.value in scale_fill_gradientn
ggplotly ignores na.value colour (e.g.: in scale_fill_gradientn and others) [bug]
Jun 5, 2021
Code to replicate the bug:
Output in ggplot2:
But this is how it looks in plotly:
This is the cause of talgalili/heatmaply#122
I've used this in the latest cutting edge ggplot2 and plotly
The text was updated successfully, but these errors were encountered: