Skip to content

scale_shape_identity doesn't work with guide = 'legend' #3029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
caayala opened this issue Dec 7, 2018 · 3 comments · Fixed by #3075
Closed

scale_shape_identity doesn't work with guide = 'legend' #3029

caayala opened this issue Dec 7, 2018 · 3 comments · Fixed by #3075
Labels
tidy-dev-day 🤓 Tidyverse Developer Day

Comments

@caayala
Copy link

caayala commented Dec 7, 2018

Related to issue #402 and #2112, scale_shape_identity works with a continues variable but with the legend attribute, it doesn't.

library(ggplot2)

df2 <- data.frame(x = 1:5 , y = 1:10, z = 1:10)
s <- ggplot(df2, aes(x = x, y = y))
s + 
  geom_point(aes(shape = z), size = 4) + 
  scale_shape_identity(guide = 'legend')
#> Error: Continuous value supplied to discrete scale

Created on 2018-12-07 by the reprex package (v0.2.1)

@clauswilke
Copy link
Member

Looks like a typo in line 84:

scale_shape_identity <- function(..., guide = "none") {
sc <- continuous_scale("shape", "identity", identity_pal(), ..., guide = guide,
super = ScaleDiscreteIdentity)

For a continuous scale, the last argument should be super = ScaleContinuousIdentity.

As a workaround, use scale_continuous_identity():

library(ggplot2)

df2 <- data.frame(x = 1:5 , y = 1:10, z = 1:10)
s <- ggplot(df2, aes(x = x, y = y))
s + 
  geom_point(aes(shape = z), size = 4) + 
  scale_continuous_identity(aesthetics = 'shape', guide = 'legend')

Created on 2018-12-07 by the reprex package (v0.2.1)

@karawoo karawoo added the tidy-dev-day 🤓 Tidyverse Developer Day label Jan 9, 2019
@malcolmbarrett
Copy link
Contributor

I'll work on this

@lock
Copy link

lock bot commented Jul 18, 2019

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/

@lock lock bot locked and limited conversation to collaborators Jul 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tidy-dev-day 🤓 Tidyverse Developer Day
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants