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
If you use fine-grained settings with show.legend, the legend for a continuous fill variable is not drawn. E.g. this:
library(ggplot2)
library(dplyr)
tribble(
~x1, ~y1, ~x2, ~y2, ~id, ~id_int,
1, 1, 2, 2, "A", 1,
2, 2, 3, 3, "B", 2
) %>%
ggplot(aes(xmin=x1, ymin=y1, xmax=x2, ymax=y2, fill=id_int)) +# could also do show.legend = c(size = FALSE) here and get the same# result; in both cases I would have expected the fill legend to show up
geom_rect(show.legend= c(size=FALSE, fill=TRUE))
I chose size here as an unrelated variable, it could be anything. This problem also happens on geoms other than rect, so I don't think it's a problem there.
I would expect output that looks like this:
FWIW, with a discrete variable for the fill, it does work as expected:
library(ggplot2)
library(dplyr)
tribble(
~x1, ~y1, ~x2, ~y2, ~id, ~id_int,
1, 1, 2, 2, "A", 1,
2, 2, 3, 3, "B", 2
) %>%
ggplot(aes(xmin=x1, ymin=y1, xmax=x2, ymax=y2, fill=id)) +# could also do show.legend = c(size = FALSE) here and get the correct result
geom_rect(show.legend= c(size=FALSE, fill=TRUE))
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/
lockbot
locked and limited conversation to collaborators
Feb 22, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
If you use fine-grained settings with
show.legend
, the legend for a continuous fill variable is not drawn. E.g. this:Created on 2019-07-28 by the reprex package (v0.3.0)
I chose
size
here as an unrelated variable, it could be anything. This problem also happens on geoms other thanrect
, so I don't think it's a problem there.I would expect output that looks like this:
FWIW, with a discrete variable for the fill, it does work as expected:
Created on 2019-07-28 by the reprex package (v0.3.0)
I tested on the github version of ggplot2 as of today (2019-07-28). Session info:
The text was updated successfully, but these errors were encountered: