I'm trying to construct a plot where I plot normally distributed variables showing their mean on the x-axis and the standard deviation (SD) on the y-axis. Kinda like a density plot, but instead of having the density on the y-axis I want to have the SD (value).
I'm working with the data below,
set.seed(1)
mu1 <- rnorm(10^5, mean = 1, sd = 1)
mu3 <- rnorm(10^5, mean = 3, sd = 2)
two normally distributed variables. Here their mean and sd,
# install.packages("tidyverse", dependencies = TRUE)
require(tidyverse)
tibble(mu1, mu3) %>% summarise_all(funs(mean, sd))
#> # A tibble: 1 x 4
#> mu1_mean mu3_mean mu1_sd mu3_sd
#> <dbl> <dbl> <dbl> <dbl>
#> 1 0.9993454 3.000825 0.9982848 1.998234
I've played around with ggplot2, and other tidyverse packages, to get closer to what I want. I've also tried copying this function from a box-plot doing something similar, having succeeded yet.
Here is my start,
tibble(mu1, mu3) %>% gather() %>% ggplot() +
geom_density(aes(x = value, colour = key)) +
labs(x = 'mean', y = 'currently density, but I would like sd')


geom_density()is for) and neither the x- nor the y-axis show the mean or the standard deviation. The boxplot from the example you linked is actually conveying a similar message as the density plot, but in a different way. It, too, does not have mean of standard deviation as one of its axes. I really don't understand your question... - Stibu