I can't change the width of ggplot2 boxplot.
I know it's probably the thousandth someone make a question similar to this but after spending my last 2 hours trying to find a solution (which i rarely do) i'm all out.
Besides i guess someone knowledgeable about ggplot2 can answer in 30 seconds.
Example code of similar problem
# Code from official ggplot2 help page
# https://ggplot2.tidyverse.org/reference/geom_boxplot.html
y <- rnorm(100)
df <- data.frame(
x = 1,
y0 = min(y),
y25 = quantile(y, 0.25),
y50 = median(y),
y75 = quantile(y, 0.75),
y100 = max(y)
)
ggplot(df, aes(x)) +
geom_boxplot(
aes(ymin = y0, lower = y25, middle = y50, upper = y75, ymax = y100),
stat = "identity"
)
I tried to changed the width so it is not the whole graphic with the boxplot, to no avail. i've tried putting width = 0.5/width = 0.1 in ggplot, geom_boxplot and in aes and it changes nothing.
Can someone help? Thanks
EDIT: Thanks for the help guys. For future reference the code i used was:
y <- rnorm(100)
df <- data.frame(
x = 1,
y0 = min(y),
y25 = quantile(y, 0.25),
y50 = median(y),
y75 = quantile(y, 0.75),
y100 = max(y)
)
ggplot(df, aes(as.factor(x))) +
geom_boxplot(
aes(ymin = y0, lower = y25, middle = y50, upper = y75, ymax = y100),
width = 0.1,
stat = "identity"
)
ggplot(df, aes(as.factor(x))) + ...
and thenwidth = .1
(or whatever) ingeom_boxplot()
– markusxlim
). – Axeman