We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
create.violinplot
I'm trying to add median points to a violin plot when having multiple panels: i.e. formula = outcome ~ first.group.var | second.group.var.
formula = outcome ~ first.group.var | second.group.var
I can't figure out how to get the extra.points argument to work with panels, but I found a workaround using + layer(panel.points(..)):
extra.points
+ layer(panel.points(..))
suppressPackageStartupMessages(library(BoutrosLab.plotting.general)); set.seed(12345); n <- 1090; simple.data <- data.frame( outcome = c( rnorm(n = n/2, mean = 0), rnorm(n = n/2, mean = 3) ), first.group.var = as.factor(sample(LETTERS[1:2],n,TRUE)) ); simple.data$second.group.var <- c( rep('group.1', n / 2), rep('group.2', n / 2) ); medians <- aggregate( x = outcome ~ first.group.var + second.group.var, data = simple.data, FUN = median );
create.violinplot( formula = outcome ~ first.group.var | second.group.var, resolution = 100, data = simple.data, extra.points = medians$outcome, extra.points.pch = 21, extra.points.col = c('blue'), extra.points.cex = 1.5, xlab.label = '' );
create.violinplot( formula = outcome ~ first.group.var | second.group.var, resolution = 100, data = simple.data, extra.points = list( medians$outcome[medians$second.group.var == 'group.1'], medians$outcome[medians$second.group.var == 'group.2'] ), extra.points.pch = 21, extra.points.col = c('blue'), extra.points.cex = 1.5, xlab.label = '' );
+ layer(panel.points(...))
violin <- create.violinplot( formula = outcome ~ first.group.var | second.group.var, resolution = 100, data = simple.data, ); extra.points.x <- list(1:2, 1:2); extra.points.y <- list( medians$outcome[medians$second.group.var == 'group.1'], medians$outcome[medians$second.group.var == 'group.2'] ); violin + layer(panel.points( x = extra.points.x[[panel.number()]], y = extra.points.y[[panel.number()]], pch = 21, col = 'blue', fill = 'blue', cex = 1.5 ))
Created on 2024-05-31 with reprex v2.0.2
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm trying to add median points to a violin plot when having multiple panels: i.e.
formula = outcome ~ first.group.var | second.group.var
.I can't figure out how to get the
extra.points
argument to work with panels, but I found a workaround using+ layer(panel.points(..))
:Attempt 1: try passing vector to
extra.points
Attempt 2: try passing list to
extra.points
, one vector per panelSolution using
+ layer(panel.points(...))
Created on 2024-05-31 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: