I have an issue about to draw a trendline in between each panel of in facet_grid
and want to label variable
values as shown like this;
same as other varibles you can imagine. How can we do that ?
here is my df
and ggplot
code to create this density facet_grid without tracing lines
fidel <- rep(seq(-30,30,30),each=5)
resp <- replicate(3,c(sort(10^runif(5,-6,0),decreasing=TRUE), sort(10^runif(5,-4,0),decreasing=TRUE),sort(10^runif(5,-2,0),decreasing=TRUE)))
Wdd <- rep(seq(1:5),times=3)
df <- data.frame(fidel,resp,Wdd)
library(reshape2) #for wide to long format
df_new <- melt(df,id=c("fidel","Wdd"))
ggplot(df_new, aes(x=value,fill=factor(Wdd)))+
geom_density(alpha=.5,adjust=0.5)+
scale_x_log10(breaks = c(1e-5,1e-3,1e-1,1),limits = c(1e-6,1))+
scale_y_continuous(breaks=seq(0,1,0.2),limits=c(0,1))+
facet_grid(fidel~Wdd,scales="free_x")+
theme(legend.position = "top")