### Installation (Development Version) Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Install the development version of ggbeeswarm from GitHub. ```r devtools::install_github("eclarke/ggbeeswarm") ``` -------------------------------- ### Installation Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Install the ggbeeswarm package from CRAN. ```r install.packages('ggbeeswarm') ``` -------------------------------- ### geom_beeswarm Example Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_beeswarm on the iris dataset. ```r ggplot(iris, aes(Species, Sepal.Length)) + geom_beeswarm() + ggtitle("Beeswarm") ``` -------------------------------- ### Standard License Notice Source: https://github.com/eclarke/ggbeeswarm/blob/main/LICENSE.md This is the standard notice to attach to the start of each source file to state the exclusion of warranty and provide copyright information. ```text Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Categorical x-axis Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of using geom_beeswarm with a categorical x-axis. ```r ggplot(mpg,aes(class, hwy)) + geom_beeswarm(size=1.1) ``` -------------------------------- ### Terminal Interaction Notice Source: https://github.com/eclarke/ggbeeswarm/blob/main/LICENSE.md This is a short notice to display when a program starts in interactive mode, informing users about its licensing and warranty. ```text Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. ``` -------------------------------- ### Different point distribution priority: Density Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of 'density' point distribution priority in geom_beeswarm. ```r ggplot(dat,aes(x,y)) + geom_beeswarm(cex=2,priority='density') + ggtitle('Density') + scale_x_continuous(expand=expansion(add=c(0.5,.5))) ``` -------------------------------- ### Corral runaway points: gutter Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of 'gutter' corral method for geom_beeswarm. ```r p + geom_beeswarm(cex = 2.5, corral = "gutter", corral.width = 0.9) + ggtitle('corral = "gutter"') ``` -------------------------------- ### Different point distribution priority: Random Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of 'random' point distribution priority in geom_beeswarm. ```r ggplot(dat,aes(x,y)) + geom_beeswarm(cex=2,priority='random') + ggtitle('Random') + scale_x_continuous(expand=expansion(add=c(0.5,.5))) ``` -------------------------------- ### Corral runaway points: none Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of 'none' corral method for geom_beeswarm. ```r set.seed(1995) df2 <- data.frame( y = rnorm(1000), id = sample(c("G1", "G2", "G3"), size = 1000, replace = TRUE) ) p <- ggplot(df2, aes(x = id, y = y, colour = id)) # use corral.width to control corral width p + geom_beeswarm(cex = 2.5, corral = "none", corral.width = 0.9) + ggtitle('corral = "none" (default)') ``` -------------------------------- ### Different point distribution priority: Default (ascending) Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of default (ascending) point distribution priority in geom_beeswarm. ```r 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(cex=2) + ggtitle('Default (ascending)') + scale_x_continuous(expand=expansion(add=c(0.5,.5))) ``` -------------------------------- ### Categorical y-axis Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of using geom_beeswarm with a categorical y-axis. ```r ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.5) ``` -------------------------------- ### Automatic dodging Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of automatic dodging with geom_beeswarm when a color aesthetic is mapped. ```r ggplot(sub_mpg, aes(class, displ, color=factor(cyl))) + geom_beeswarm(dodge.width=0.5) ``` -------------------------------- ### Corral runaway points: wrap Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of 'wrap' corral method for geom_beeswarm. ```r p + geom_beeswarm(cex = 2.5, corral = "wrap", corral.width = 0.9) + ggtitle('corral = "wrap"') ``` -------------------------------- ### Corral runaway points: random Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of 'random' corral method for geom_beeswarm. ```r p + geom_beeswarm(cex = 2.5, corral = "random", corral.width = 0.9) + ggtitle('corral = "random"') ``` -------------------------------- ### Different point distribution priority: Descending Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of 'descending' point distribution priority in geom_beeswarm. ```r ggplot(dat,aes(x,y)) + geom_beeswarm(cex=2,priority='descending') + ggtitle('Descending') + scale_x_continuous(expand=expansion(add=c(0.5,.5))) ``` -------------------------------- ### Corral runaway points: omit Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Example of 'omit' corral method for geom_beeswarm, which removes runaway points. ```r p + geom_beeswarm(cex = 2.5, corral = "omit", corral.width = 0.9) + ggtitle('corral = "omit"') ## Warning: Removed 303 rows containing missing values (geom_point). ``` -------------------------------- ### Alternative methods: swarm Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Demonstrates the 'swarm' method for geom_beeswarm. ```r df <- data.frame( x = "A", y = sample(1:100, 200, replace = TRUE) ) ggplot(df, aes(x = x, y = y)) + geom_beeswarm(cex = 2.5, method = "swarm") + ggtitle('method = "swarm" (default)') ``` -------------------------------- ### Alternative methods: center Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Demonstrates the 'center' method for geom_beeswarm. ```r ggplot(df, aes(x = x, y = y)) + geom_beeswarm(cex = 2.5, method = "center") + ggtitle('method = "center"') ``` -------------------------------- ### Alternative methods: compactswarm Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Demonstrates the 'compactswarm' method for geom_beeswarm. ```r ggplot(df, aes(x = x, y = y)) + geom_beeswarm(cex = 2.5, method = "compactswarm") + ggtitle('method = "compactswarm"') ``` -------------------------------- ### Alternative methods: square Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Demonstrates the 'square' method for geom_beeswarm. ```r ggplot(df, aes(x = x, y = y)) + geom_beeswarm(cex = 2.5, method = "square") + ggtitle('method = "square"') ``` -------------------------------- ### Alternative methods: hex Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Demonstrates the 'hex' method for geom_beeswarm. ```r ggplot(df, aes(x = x, y = y)) + geom_beeswarm(cex = 2.5, method = "hex") + ggtitle('method = "hex"') ``` -------------------------------- ### Comparison with geom_quasirandom Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Compare geom_quasirandom with geom_jitter on the iris dataset. ```r ggplot(iris,aes(Species, Sepal.Length)) + geom_quasirandom() ``` -------------------------------- ### geom_quasirandom with Tukey Dense Method Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_quasirandom with the 'tukeyDense' method. ```r ggplot(iris, aes(Species, Sepal.Length)) + geom_quasirandom(method = "tukeyDense") + ggtitle("Tukey + density") ``` -------------------------------- ### Comparison with geom_jitter Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Compare geom_jitter with geom_quasirandom on the iris dataset. ```r set.seed(12345) library(ggplot2) library(ggbeeswarm) #compare to jitter ggplot(iris,aes(Species, Sepal.Length)) + geom_jitter() ``` -------------------------------- ### geom_quasirandom with Automatic Dodging Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Demonstrates automatic dodging with geom_quasirandom when a grouping variable is categorical and dodge.width is specified. ```r sub_mpg <- mpg[mpg$class %in% c("midsize", "pickup", "suv"),] ggplot(sub_mpg, aes(class, displ, color=factor(cyl))) + geom_quasirandom(dodge.width=1) ``` -------------------------------- ### geom_quasirandom with Frowney Method Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_quasirandom with the 'frowney' method. ```r ggplot(iris, aes(Species, Sepal.Length)) + geom_quasirandom(method = "frowney") + ggtitle("Banded frowns") ``` -------------------------------- ### geom_quasirandom with Tukey Method Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_quasirandom with the 'tukey' method. ```r ggplot(iris, aes(Species, Sepal.Length)) + geom_quasirandom(method = "tukey") + ggtitle("Tukey texture") ``` -------------------------------- ### geom_quasirandom with Pseudorandom Method Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_quasirandom with the 'pseudorandom' method. ```r ggplot(iris, aes(Species, Sepal.Length)) + geom_quasirandom(method = "pseudorandom") + ggtitle("Jittered density") ``` -------------------------------- ### geom_quasirandom with Smiley Method Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_quasirandom with the 'smiley' method. ```r ggplot(iris, aes(Species, Sepal.Length)) + geom_quasirandom(method = "smiley") + ggtitle("Banded smiles") ``` -------------------------------- ### geom_quasirandom with Variable Width Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_quasirandom with varwidth=TRUE to adjust width dynamically. ```r ggplot(mpg,aes(class, hwy)) + geom_quasirandom(varwidth = TRUE) ``` -------------------------------- ### geom_beeswarm on mpg Dataset Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_beeswarm on the mpg dataset with a specified size. ```r ggplot(mpg,aes(class, hwy)) + geom_beeswarm(size=.5) ``` -------------------------------- ### Default geom_quasirandom Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Default usage of geom_quasirandom on the mpg dataset. ```r ggplot(mpg,aes(class, hwy)) + geom_quasirandom() ``` -------------------------------- ### Points escaping the plot Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Demonstrates how to use scale_y_discrete to prevent points from escaping the plot area. ```r ggplot(mpg,aes(hwy, class)) + geom_beeswarm(size=.5) + scale_y_discrete(expand=expansion(add=c(0.5,1))) ``` -------------------------------- ### geom_beeswarm with Side Argument Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_beeswarm with the side argument set to 1L. ```r ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm(side = 1L) ``` -------------------------------- ### geom_quasirandom with Categorical Y-axis Source: https://github.com/eclarke/ggbeeswarm/blob/main/README.md Using geom_quasirandom with a categorical y-axis. ```r ggplot(mpg,aes(hwy, class)) + geom_quasirandom(groupOnX=FALSE) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.