I am interested in making a similar plot like this for iris data, with summary statistics produced on the plot: https://i.sstatic.net/Zyv2s.jpg
I am following this post over here: How to add summary statistics in histogram plot using ggplot2?
df <- iris
df.m <- melt(df, id="Species")
#Calculating the summary statistics
summ <- df.m %>%
group_by(variable) %>%
summarize(min = min(value), max = max(value),
mean = mean(value), q1= quantile(value, probs = 0.25),
median = median(value), q3= quantile(value, probs = 0.75),
sd = sd(value))
I then modified the code to make density plots instead of histograms:
p1 <- ggplot(df.m) + geom_density(aes(x = value), fill = "grey", color = "black") +
facet_wrap(~variable, scales="free", ncol = 2)+ theme_bw()
I seem to be having a problem over here:
p1+geom_density(data=summ,label =split(summ,summ$variable),
npcx = 0.00, npcy = 1, hjust = 0, vjust = 1,size=2)
Does anyone know what the problem is? Also, is it possible to accomplish this with only ggplot2? I am working with a computer where I do not have the admin privileges to download many libraries (I have reshape2, dplyr, ggplot2). Should this be done using the annotate() function in ggplot2? And is there a way to change the x-axis for each graph to "log"?

