-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
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.boxplot: different text above each box #137
Comments
Ahh I'm now thinking Nevertheless, how can I get unique text above each box in a single panel plot? EDIT: I suppose one option is to use |
I think your edit is probably the best solution ( You are correct about the panel and grouping. See this example: library(BoutrosLab.plotting.general);
set.seed(779);
groupA <- rnorm(n = 100, mean = 10, sd = 2);
groupB <- rnorm(n = 134, mean = 10.5, sd = 2);
# Create data frame for plotting
to.plot <- data.frame(
y = rep(
c('1', '2'),
times = c(100, 134)
),
x = c(groupA, groupB)
);
to.plot.groups <- rbind(
data.frame(to.plot, z = 1),
data.frame(to.plot, z = 2)
)
to.plot.groups$z <- as.factor(to.plot.groups$z)
# replicate(2, to.plot)
# Plot and display difference
create.boxplot(
formula = x ~ y | z,
data = to.plot.groups,
add.stripplot = TRUE,
add.text = TRUE,
text.labels = c('A', 'B'),
text.x = c(1, 2),
text.y = 15.3,
text.col = 'black',
text.cex = 1.5,
text.fontface = 'bold',
ylimits = c(
min(to.plot$x) - abs(min(to.plot$x) * 0.1),
max(to.plot$x) + abs(max(to.plot$x) * 0.1)
)
); Created on 2023-07-13 with reprex v2.0.2 Note that this behavior is not consistent across different plot types (not sure what the "correct" way should be). See how it works for scatterplot: library(BoutrosLab.plotting.general);
#> Loading required package: lattice
#> Loading required package: latticeExtra
#> Loading required package: cluster
#> Loading required package: hexbin
#> Loading required package: grid
#>
#> Attaching package: 'BoutrosLab.plotting.general'
#> The following object is masked from 'package:stats':
#>
#> dist
set.seed(13);
to.plot.scatter <- data.frame(
x = rnorm(100),
y = rnorm(100),
z = c(1,2)
);
create.scatterplot(
y ~ x,
data = to.plot.scatter,
add.text = TRUE,
text.labels = c('a', 'b'),
text.x = c(1, 2),
text.y = 1
) create.scatterplot(
y ~ x | z,
data = to.plot.scatter,
add.text = TRUE,
text.labels = c('a', 'b'),
text.x = c(1, 2),
text.y = 1
); Created on 2023-07-13 with reprex v2.0.2 |
For
create.boxplot
, I am trying to add unique text above each box. The documentation fortext.labels
suggests this should be possible:However, when I pass a vector
c('A', 'B')
totext.labels
, it only plots the first elementA
above each box:Created on 2023-07-13 by the reprex package (v2.0.1)
The text was updated successfully, but these errors were encountered: