diff --git a/README.Rmd b/README.Rmd index 718cf72..1c4e34d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -85,6 +85,7 @@ ggplot(iris,aes(Species, Sepal.Length)) + geom_quasirandom(method='tukeyDense') ggplot(iris,aes(Species, Sepal.Length)) + geom_quasirandom(method='frowney') + ggtitle('Banded frowns') ggplot(iris,aes(Species, Sepal.Length)) + geom_quasirandom(method='smiley') + ggtitle('Banded smiles') ggplot(iris,aes(Species, Sepal.Length)) + geom_quasirandom(method='pseudorandom') + ggtitle('Jittered density') +ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm() + ggtitle('Beeswarm') ``` ### geom_beeswarm() @@ -93,18 +94,26 @@ Using `geom_beeswarm`: ```{r ggplot2-beeswarm} ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm() -ggplot(mpg,aes(class, hwy)) + geom_beeswarm() +ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm(beeswarmArgs=list(side=1)) +ggplot(mpg,aes(class, hwy)) + geom_beeswarm(size=.5) # With categorical y-axis -ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.6,groupOnX=FALSE) +ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.5,groupOnX=FALSE) # Also watch out for points escaping from the plot with geom_beeswarm -ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.6,groupOnX=FALSE) + scale_y_discrete(expand=expand_scale(add=c(0.5,1))) +ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.5,groupOnX=FALSE) + scale_y_discrete(expand=expand_scale(add=c(0.5,1))) ggplot(mpg,aes(class, hwy)) + geom_beeswarm(size=1.1) -ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm(size=1.2,priority='density') # With automatic dodging ggplot(sub_mpg, aes(class, displ, color=factor(cyl))) + geom_beeswarm(dodge.width=0.5) + +#With different beeswarm point distribution priority +dat<-data.frame(x=rep(1:3,c(20,40,80))) +dat$y<-rnorm(nrow(dat),dat$x) +ggplot(dat,aes(x,y)) + geom_beeswarm(size=2) + ggtitle('Default (ascending)') + scale_x_continuous(expand=expand_scale(add=c(0.5,.5))) +ggplot(dat,aes(x,y)) + geom_beeswarm(size=2,priority='descending') + ggtitle('Descending') + scale_x_continuous(expand=expand_scale(add=c(0.5,.5))) +ggplot(dat,aes(x,y)) + geom_beeswarm(size=2,priority='density') + ggtitle('Density') + scale_x_continuous(expand=expand_scale(add=c(0.5,.5))) +ggplot(dat,aes(x,y)) + geom_beeswarm(size=2,priority='random') + ggtitle('Random') + scale_x_continuous(expand=expand_scale(add=c(0.5,.5))) ``` diff --git a/README.md b/README.md index 3634cb4..6a85816 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,12 @@ ggplot(iris, aes(Species, Sepal.Length)) + geom_quasirandom(method = "pseudorand plot of chunk ggplot2-methods +```r +ggplot(iris, aes(Species, Sepal.Length)) + geom_beeswarm() + ggtitle("Beeswarm") +``` + +plot of chunk ggplot2-methods + ### geom_beeswarm() Using `geom_beeswarm`: @@ -138,33 +144,33 @@ ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm() plot of chunk ggplot2-beeswarm ```r -ggplot(mpg,aes(class, hwy)) + geom_beeswarm() +ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm(beeswarmArgs=list(side=1)) ``` plot of chunk ggplot2-beeswarm ```r -# With categorical y-axis -ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.6,groupOnX=FALSE) +ggplot(mpg,aes(class, hwy)) + geom_beeswarm(size=.5) ``` plot of chunk ggplot2-beeswarm ```r -# Also watch out for points escaping from the plot with geom_beeswarm -ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.6,groupOnX=FALSE) + scale_y_discrete(expand=expand_scale(add=c(0.5,1))) +# With categorical y-axis +ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.5,groupOnX=FALSE) ``` plot of chunk ggplot2-beeswarm ```r -ggplot(mpg,aes(class, hwy)) + geom_beeswarm(size=1.1) +# Also watch out for points escaping from the plot with geom_beeswarm +ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.5,groupOnX=FALSE) + scale_y_discrete(expand=expand_scale(add=c(0.5,1))) ``` plot of chunk ggplot2-beeswarm ```r -ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm(size=1.2,priority='density') +ggplot(mpg,aes(class, hwy)) + geom_beeswarm(size=1.1) ``` plot of chunk ggplot2-beeswarm @@ -176,6 +182,33 @@ ggplot(sub_mpg, aes(class, displ, color=factor(cyl))) + geom_beeswarm(dodge.widt plot of chunk ggplot2-beeswarm +```r +#With different beeswarm point distribution priority +dat<-data.frame(x=rep(1:3,c(20,40,80))) +dat$y<-rnorm(nrow(dat),dat$x) +ggplot(dat,aes(x,y)) + geom_beeswarm(size=2) + ggtitle('Default (ascending)') + scale_x_continuous(expand=expand_scale(add=c(0.5,.5))) +``` + +plot of chunk ggplot2-beeswarm + +```r +ggplot(dat,aes(x,y)) + geom_beeswarm(size=2,priority='descending') + ggtitle('Descending') + scale_x_continuous(expand=expand_scale(add=c(0.5,.5))) +``` + +plot of chunk ggplot2-beeswarm + +```r +ggplot(dat,aes(x,y)) + geom_beeswarm(size=2,priority='density') + ggtitle('Density') + scale_x_continuous(expand=expand_scale(add=c(0.5,.5))) +``` + +plot of chunk ggplot2-beeswarm + +```r +ggplot(dat,aes(x,y)) + geom_beeswarm(size=2,priority='random') + ggtitle('Random') + scale_x_continuous(expand=expand_scale(add=c(0.5,.5))) +``` + +plot of chunk ggplot2-beeswarm + ------ Authors: Erik Clarke and Scott Sherrill-Mix diff --git a/README_files/figure-html/ggplot2-beeswarm-10.png b/README_files/figure-html/ggplot2-beeswarm-10.png new file mode 100644 index 0000000..d652ef6 Binary files /dev/null and b/README_files/figure-html/ggplot2-beeswarm-10.png differ diff --git a/README_files/figure-html/ggplot2-beeswarm-11.png b/README_files/figure-html/ggplot2-beeswarm-11.png new file mode 100644 index 0000000..7b8d02f Binary files /dev/null and b/README_files/figure-html/ggplot2-beeswarm-11.png differ diff --git a/README_files/figure-html/ggplot2-beeswarm-2.png b/README_files/figure-html/ggplot2-beeswarm-2.png index 8c7ef1b..40e3291 100644 Binary files a/README_files/figure-html/ggplot2-beeswarm-2.png and b/README_files/figure-html/ggplot2-beeswarm-2.png differ diff --git a/README_files/figure-html/ggplot2-beeswarm-3.png b/README_files/figure-html/ggplot2-beeswarm-3.png index 092bcb8..3274dea 100644 Binary files a/README_files/figure-html/ggplot2-beeswarm-3.png and b/README_files/figure-html/ggplot2-beeswarm-3.png differ diff --git a/README_files/figure-html/ggplot2-beeswarm-4.png b/README_files/figure-html/ggplot2-beeswarm-4.png index 772115d..1d7f312 100644 Binary files a/README_files/figure-html/ggplot2-beeswarm-4.png and b/README_files/figure-html/ggplot2-beeswarm-4.png differ diff --git a/README_files/figure-html/ggplot2-beeswarm-5.png b/README_files/figure-html/ggplot2-beeswarm-5.png index 8da6385..be12be3 100644 Binary files a/README_files/figure-html/ggplot2-beeswarm-5.png and b/README_files/figure-html/ggplot2-beeswarm-5.png differ diff --git a/README_files/figure-html/ggplot2-beeswarm-6.png b/README_files/figure-html/ggplot2-beeswarm-6.png index 50e233c..8da6385 100644 Binary files a/README_files/figure-html/ggplot2-beeswarm-6.png and b/README_files/figure-html/ggplot2-beeswarm-6.png differ diff --git a/README_files/figure-html/ggplot2-beeswarm-8.png b/README_files/figure-html/ggplot2-beeswarm-8.png new file mode 100644 index 0000000..c076911 Binary files /dev/null and b/README_files/figure-html/ggplot2-beeswarm-8.png differ diff --git a/README_files/figure-html/ggplot2-beeswarm-9.png b/README_files/figure-html/ggplot2-beeswarm-9.png new file mode 100644 index 0000000..b7d746b Binary files /dev/null and b/README_files/figure-html/ggplot2-beeswarm-9.png differ diff --git a/README_files/figure-html/ggplot2-methods-6.png b/README_files/figure-html/ggplot2-methods-6.png new file mode 100644 index 0000000..c9b07ee Binary files /dev/null and b/README_files/figure-html/ggplot2-methods-6.png differ diff --git a/README_files/figure-html/ggplot2-methods-7.png b/README_files/figure-html/ggplot2-methods-7.png new file mode 100644 index 0000000..183ac80 Binary files /dev/null and b/README_files/figure-html/ggplot2-methods-7.png differ diff --git a/inst/doc/usageExamples.pdf b/inst/doc/usageExamples.pdf index dc761ce..9dfe520 100644 Binary files a/inst/doc/usageExamples.pdf and b/inst/doc/usageExamples.pdf differ