geom_tile with only one possible value is grey
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
There seems to be a problem when a fill value in geom_tile only has one possible value.
Example below. You get grey instead of the color ggplot2 uses. This is an issue when you facet a geom_tile and one facet only contains one possible value. Then you get a completely grey tile instead of what color the value should have.
I'm guessing this has to do with scaling? Since you get NaN if you scale only identical values.
pp <- function (n,r=4) {
x <- seq(-r*pi, r*pi, len=n)
df <- expand.grid(x=x, y=x)
df$r <- sqrt(df$x^2 + df$y^2)
# df$z <- 1
df$z <- c(1,2)
df
}
p <- ggplot(pp(20), aes(x=x,y=y))
p <- p + geom_tile(aes(fill=z))
p
ggplotly(p)
ggplot:

plotly:

pp <- function (n,r=4) {
x <- seq(-r*pi, r*pi, len=n)
df <- expand.grid(x=x, y=x)
df$r <- sqrt(df$x^2 + df$y^2)
df$z <- 1
# df$z <- c(1,2)
df
}
p <- ggplot(pp(20), aes(x=x,y=y))
p <- p + geom_tile(aes(fill=z))
p
ggplotly(p)
ggplot:

plotly:

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 by running the two supplied R examples and compare the ggplot and ggplotly output, including the single-value and faceted cases. Trace how ggplotly handles the geom_tile fill scale; done means a single possible fill value renders in its intended color instead of grey.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100