So I have this code
ggplot(data, aes(x=price, y=values)) +
# add colourful lines
geom_line(aes(group=group, color=group)) +
# add two box plots
geom_boxplot(data=df, aes(x="z_lnprice_new", y=x_lnprice_new)) +
geom_boxplot(data=df, aes(x='a_lnprice_new', y=b_lnprice_old)) +
# delete the legend
theme(legend.position="none")
and have this graph:
Also I want to add the jitter
on the boxplots. But if I just add
+ geom_jitter(alpha=0.5, aes(price, values, color=group),
position = position_jitter(width = .2))
I'm having the jitter on the lines geom_line
, but not on the boxplots.
Is that possible?
P.S.: the whole chunk of code with data Google Drive, .csv, 25 kB
df <- data.frame(b_lnprice_old= sort(nb_firm_two_price[[175]]),
x_lnprice_new = sort(nb_firm_two_price[[176]]))
data <- data.frame(group = factor(1:nrow(df)),
price=c(rep('b_lnprice_old',nrow(df)),
rep('x_lnprice_old',nrow(df))),
values=c(df$b_lnprice_old,df$x_lnprice_new))
ggplot(data, aes(x=price, y=values)) +
geom_line(aes(group=group, color=group)) +
geom_boxplot(data=df, aes(x="z_lnprice_new", y=x_lnprice_new)) +
geom_boxplot(data=df, aes(x='a_lnprice_new', y=b_lnprice_old)) +
theme(legend.position="none")