plotly / plotly/plotly.R

geom_tile with only one possible value is grey

Open
#907 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug ggplotly
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:
image

plotly:
image

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:
image

plotly:
image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.