Missing colors in heatmap if values are the identical
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Hello!
when creating a heatmap where values are all the same on a continuous scale, I get the expected colors from ggplot. However, when I put my ggplot into ggplotly, the colors are gone and it's all gray. Only happends, when values are identical. Happens with version 4.9.3 of plotly.
library(ggplot2)
library(dplyr)
library(plotly)
data <- tibble(hour = c(1, 1, 2, 2), day = c(1, 2, 1, 2), evaluation = c(1, 1, 1, 1))
g <- ggplot(data = data, mapping = aes(x = hour, y = day))
g <- g + geom_tile(aes(fill = evaluation), color = "white")
g <- g + scale_fill_gradientn(limits = c(0, 1), colours = c("red", "green"), name = "Availability")
print(g) # ok, all colors are green as expected
print(ggplotly(g)) # not ok, colors in heatmap are gray, expected to be green
Please let me know if you need more explanation or additional information to track this down.
Thank you and kind regards,
Heiko
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducible R example in the issue and trace the ggplotly conversion for a continuous heatmap whose evaluation values are identical. Compare the ggplot and ggplotly outputs, then verify that the converted tiles use the expected green color instead of gray.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100