Reputation: 1860
I want to visualize my data using Boxplot.
I have created a boxplot and a stripchar using the follwonig comands:
adjbox(nkv.murgang$NK, main = "NKV, Murgang - Skewness Adjusted", horizontal = T, axes = F,
staplewex = 1, xlab = "Nutzen Kosten Verhältnis")
stripchart(nkv.murgang$NK, main = "NKV, Murgang - Stripchart", horizontal = T, pch = 1,
method = "jitter", xlab = "Nutzen Kosten Verhältnis")
However I cannot figure out how to incorporate the corresponding five number statistics into the graph (min, 1st Qu., Mean, 3rd Qu., Max). I want them to be display next to the whiskers.
What is my y-axis
in this case?
Additionaly, I also want to highlight the mean and median with different colours. Something like this:
is it possible to combine this two into one graph?
Thanks for any input. I know this seems very basic, but I am stuck here...
Upvotes: 1
Views: 1519
Reputation: 1860
Instead of using adjbox, use ggplot:
There is a trick for the unknown x-axis: x = factor(0)
.
ggplot(nkv.murgang, aes(x = factor(0), nkv.murgang$NK)) +
geom_boxplot(notch = F, outlier.color = "darkgrey", outlier.shape = 1,
color = "black", fill = "darkorange", varwidth = T) +
ggtitle("NKV Murgang - Einfamilienhaus") +
labs(x = "Murgang", y = "Nutzen / Konsten \n Verhälhniss") +
stat_summary(geom = "text", fun.y = quantile,
aes(label=sprintf("%1.1f", ..y..)),
position=position_nudge(x=0.4), size=3.5)
This question explains.
Upvotes: 1
Reputation: 21497
You can combine a boxplot with a point-plot using ggplot2
as follows
require(ggplot2)
ggplot(mtcars, aes(x = as.factor(gear), y = wt)) +
geom_boxplot() +
geom_jitter(aes(col = (cyl == 4)), width = 0.1)
The result would be:
Upvotes: 1