Skip to content
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

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

Closed
caayala opened this issue Dec 7, 2018 · 3 comments
Closed

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

caayala opened this issue Dec 7, 2018 · 3 comments

Comments

@caayala
Copy link

@caayala 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

@clauswilke clauswilke commented Dec 7, 2018

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)

@malcolmbarrett
Copy link
Contributor

@malcolmbarrett malcolmbarrett commented Jan 19, 2019

I'll work on this

@lock
Copy link

@lock 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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants