-
Notifications
You must be signed in to change notification settings - Fork 633
Conversion not implemented for geom_jitter #221
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
I tried using a slight hack (position_jitter with geom_point) from here: # boxplot of normalized water use
p = ggplot(NW2)
p = p + geom_point(aes(factor(year),norm_withdrawal,color=factor(norm_withdrawal)), alpha=0.6,
size=3, position = "jitter") + guides(color=FALSE)
p = p + geom_boxplot(aes(factor(year),norm_withdrawal),alpha=0.8)
p = p + xlab("Years") + ylab("Public Supply withdrawal/county pop")
p = p + ggtitle("Normalized Public Supply wthdrawal for 315 MSAs") + theme_grey(base_size = 16) But the points are not jittered |
Thanks for letting us know. I will look into this. -- Baobao Zhang
|
I think I have a solution. Based on the hack that @scottcworland noted, I added a p <- ggplot(mpg, aes(displ, hwy))
p + geom_jitter(position = position_jitter())
py$ggplotly(p + geom_jitter()) Two questions:
|
Thanks @13bzhang , these are really great questions. Regarding the first one, the policy is the following: all new code you write should comply with our style guide, but as you run into old code that doesn't comply, you don't have to 'fix' it. You are welcome to, but then make that a separate commit. |
Nice! For 2. We don't have a good way of doing this as part of the figure yet. In the future, once we refactor and add the tabular data methods (uploading tabular data to plotly) to the package we could upload the original columns as the "source" data |
Hi guys, I have been having trouble writing tests for this Below are my results > # Test 1
> # set up the data
> set.seed(1001)
> p1 <- ggplot() + geom_jitter(data = mpg, aes(displ, hwy), width = 1)
> head(ggplot_build2(p1)$data[[1]]$x)
[1] 1.838855 1.793010 1.994363 1.993534 2.794121 2.831024
> # test
> test_that("geom_jitter is working", {
+ set.seed(1001)
+ info <- expect_traces(p1, 1, "geom_jitter", 1001)
+ tr <- info$traces[[1]]
+ la <- info$layout
+ expect_identical(tr$type, "scatter")
+ set.seed(1001)
+ built <- ggplot_build2(p1)
+ print(head(tr$x)) # from gg2list
+ print(head(built$data[[1]]$x)) # from ggplot_build2
+ expect_identical(tr$x, built$data[[1]]$x)
+ expect_identical(tr$y, built$data[[1]]$y)
+ })
[1] "running coord_fixed-geom_jitter"
[1] 1.774830 1.763145 1.982322 2.029265 2.800319 2.822188
[1] 1.838855 1.793010 1.994363 1.993534 2.794121 2.831024
Error: Test failed: 'geom_jitter is working'
* Not expected: tr$x is not identical to built$data[[1]]$x. Differences:
Mean relative difference: 0.008040036.
* Not expected: tr$y is not identical to built$data[[1]]$y. Differences:
Mean relative difference: 0.0109569. Carson, do you have any suggestions? |
If it's too hard to set a seed, then I'd just copy and paste a vector of generated data into the test and call it a day! |
Ok, that sounds good! |
@13bzhang it's probably the case that each time you "build" a plot, you get a different jitter. So you should be careful to compare the data from the same built object Could you start a pull request so we can make comments/recommendations on commits, etc.? |
Fixed via 1993631 |
geom_jitter not converted
Warning message:
The text was updated successfully, but these errors were encountered: