SkillAgentSearch skills...

Ggbeeswarm2

Column scatter / beeswarm-style plots in ggplot2

Install / Use

/learn @csdaw/Ggbeeswarm2
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<!-- README.md is generated from README.Rmd. Please edit that file -->

ggbeeswarm2: Beeswarm-style plots with ggplot2

<!-- badges: start -->

R-CMD-check Codecov test
coverage Lifecycle:
experimental

<!-- badges: end -->

Note

This is a fork of ggbeeswarm which is in an experimental and unfinished state. Some of changes made here including additional swarming and corral methods are now available in the development version of ggbeeswarm, which is probably what you should be using.

I plan on trying out re-writing these functions (again) so that the swarming is performed based on the plotting area and size of the plotting character as opposed to just the x/y range of the data (as in ggbeeswarm).

The position_beeswarm function has been rewritten and is compatible with R >= v4.0.0. Additionally, position_beeswarm works almost identically to the beeswarm function from the beeswarm package with all the additional methods implemented (including the new compactswarm).

For example:

set.seed(123)
distro <- list(runif = runif(100, min = -3, max = 3), 
               rnorm = rnorm(100))

# beeswarm
beeswarm::beeswarm(distro, 
                   col = 2:3, pch = 16,
                   method = "hex",
                   main = "title")
## [1] "par(\"usr\") = 0" "par(\"usr\") = 1" "par(\"usr\") = 0" "par(\"usr\") = 1"
## [1] "cex.out[1]:  1"

## [1] "par(\"cex\"): 1"
## [1] "cex: 1"
## [1] "spacing: 1"
## [1] "sizeMultiplier: 1"
## [1] "VERTICAL!"
## [1] "x.size = 0.0363025210084034"
## [1] "y.size = 0.243244296807423"
# ggbeeswarm2
library(dplyr)
library(ggbeeswarm2)
<img src="man/figures/README-ex-1.png" width="576" />
distro2 <- as.data.frame(rev(distro)) %>% 
  tidyr::pivot_longer(
    everything(), 
    values_to = "value", 
    names_to = "variable"
    )

 ggplot2::ggplot(distro2, aes(x = rev(variable), y = value)) + 
   geom_beeswarm(method = "hex") + 
   scale_y_continuous(limits = c(-3, 3))
<img src="man/figures/README-ex-2.png" width="576" />
## [1] "plot.ylim.short = -3" "plot.ylim.short = 3" 
## [1] "y.range = 6"

Author: Charlotte Dawson

Original authors: Erik Clarke and Scott Sherrill-Mix

Related Skills

View on GitHub
GitHub Stars7
CategoryDevelopment
Updated2y ago
Forks1

Languages

R

Security Score

55/100

Audited on Apr 22, 2023

No findings