Discussion:
geom_density + geom_rug with position=jitter, v0.9.3
Gad Abraham
2012-12-12 23:49:25 UTC
Permalink
Hi,

I'm trying to jitter the rug in a density plot, but can't get it going,
library(ggplot2)
d <- data.frame(x=rnorm(100), y=factor(sample(0:1, 100, replace=TRUE)))
ggplot(d, aes(x, colour=y)) + geom_density() + geom_rug() # works fine
ggplot(d, aes(x, colour=y)) + geom_density() + geom_rug(position="jitter")
Error: position_jitter requires the following missing aesthetics: y

Thanks,
Gad
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggplot2_0.9.3

loaded via a namespace (and not attached):
[1] colorspace_1.2-0 dichromat_1.2-4 digest_0.6.0
grid_2.15.2 gtable_0.1.2 labeling_0.1 MASS_7.3-22
munsell_0.4
[9] plyr_1.8 proto_0.3-9.2 RColorBrewer_1.0-5
reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_2.15.2
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Winston Chang
2012-12-13 02:21:27 UTC
Permalink
You could do something like this:

library(ggplot2)
d <- data.frame(x=rnorm(100), y=factor(sample(0:1, 100, replace=TRUE)))

ggplot(d, aes(x, colour=y)) + geom_density() +
geom_rug(aes(y=y), position="jitter", sides="b")

The y position isn't actually used, but it will make position_jitter happy.
Post by Gad Abraham
Hi,
I'm trying to jitter the rug in a density plot, but can't get it going,
library(ggplot2)
d <- data.frame(x=rnorm(100), y=factor(sample(0:1, 100, replace=TRUE)))
ggplot(d, aes(x, colour=y)) + geom_density() + geom_rug() # works fine
ggplot(d, aes(x, colour=y)) + geom_density() +
geom_rug(position="jitter")
Error: position_jitter requires the following missing aesthetics: y
Thanks,
Gad
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
[1] stats graphics grDevices utils datasets methods base
[1] ggplot2_0.9.3
[1] colorspace_1.2-0 dichromat_1.2-4 digest_0.6.0
grid_2.15.2 gtable_0.1.2 labeling_0.1 MASS_7.3-22
munsell_0.4
[9] plyr_1.8 proto_0.3-9.2 RColorBrewer_1.0-5
reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_2.15.2
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Gad Abraham
2012-12-13 02:56:05 UTC
Permalink
Great, thanks Winston.
library(ggplot2)
d <- data.frame(x=rnorm(100), y=factor(sample(0:1, 100, replace=TRUE)))
ggplot(d, aes(x, colour=y)) + geom_density() +
geom_rug(aes(y=y), position="jitter", sides="b")
The y position isn't actually used, but it will make position_jitter happy.
Post by Gad Abraham
Hi,
I'm trying to jitter the rug in a density plot, but can't get it going,
library(ggplot2)
d <- data.frame(x=rnorm(100), y=factor(sample(0:1, 100, replace=TRUE)))
ggplot(d, aes(x, colour=y)) + geom_density() + geom_rug() # works fine
ggplot(d, aes(x, colour=y)) + geom_density() +
geom_rug(position="jitter")
Error: position_jitter requires the following missing aesthetics: y
Thanks,
Gad
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
[1] stats graphics grDevices utils datasets methods base
[1] ggplot2_0.9.3
[1] colorspace_1.2-0 dichromat_1.2-4 digest_0.6.0
grid_2.15.2 gtable_0.1.2 labeling_0.1 MASS_7.3-22
munsell_0.4
[9] plyr_1.8 proto_0.3-9.2 RColorBrewer_1.0-5
reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_2.15.2
--
You received this message because you are subscribed to the ggplot2 mailing list.
https://github.com/hadley/devtools/wiki/Reproducibility
More options: http://groups.google.com/group/ggplot2
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggplot2-/***@public.gmane.org
To unsubscribe: email ggplot2+unsubscribe-/***@public.gmane.org
More options: http://groups.google.com/group/ggplot2
Loading...