-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Continuous values don't work with scale_shape_identity #402
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
Comments
Shape is inherently discrete; the fact that you can't use a continuous variable isn't surprising. What ought it do? |
Prior to f175bbb, it produced a chart of all the point shapes from 1-25, by using the UPDATE: this part about It is possible to make it work by using s + geom_point(aes(shape = as.integer(z)), size = 4) + scale_shape_identity() It seems to me there are a few alternatives:
|
I think option 3 is the right one for shape scales. I made this change because the previous behaviour had broken one of the tests. |
I put a function in |
We also need to supplement the tests so this doesn't happen again. |
Hm, I was actually wrong -- wrapping it with At any rate, after playing with this some more, I think there are two challenges:
At any rate, here's a test: test_that("shape identity scale works for numerics", {
ssi <- scale_shape_identity()
expect_identical(scale_train(ssi, 1:5), 1:5)
expect_error(scale_train(ssi, c(.5, 1:4)))
}) If you don't think that the scales package should be changed, here's a quick fix for the code that's breaking R CMD check: df2 <- data.frame(x = 1:5 , y = 1:25, z = 1:25)
s <- ggplot(df2, aes(x = x, y = y))
s + geom_point(aes(shape = as.character(z)), size = 4) +
scale_shape_manual(breaks = as.character(df2$z), values = df2$z, guide = FALSE) |
Hmmm, probably just best to change the example. Otherwise we'd need to muck with a custom scale class for shape identity. |
This turned out to be much simpler than I thought - and should slightly improve performance with identity scales. |
df2 <- data.frame(x = 1:5 , y = 1:25, z = 1:25) |
@jmccreight can you please open a new issue rather than commenting on a very old issue. |
Commit f175bbb broke
R CMD check
:The text was updated successfully, but these errors were encountered: