Hi,
I would like to add common median line for each facet.
library(ggplot2)
plot8beta<-data.frame(
stringsAsFactors = FALSE,
row.names = c("1","29",
"57","85","113","141","169","197",
"225","253","281","309","337","365","393",
"421","449","477","505","533","561","589",
"617","645","673","701","729","757",
"785","813","841","869","897","925","953",
"981","1009","1037","1065","1093","1121",
"1149","1177","1205","1233","1261",
"1289","1317","1345","1373","1401","1429"),
EPG = c("EFDD",
"ALDE","EPP","EPP","S&D","EPP","EPP",
"S&D","ALDE","ALDE","S&D","S&D","EPP","ENF",
"S&D","S&D","ECR","EPP","Greens/EFA",
"S&D","ECR","ALDE","S&D","GUE/NGL","EPP",
"ALDE","Greens/EFA","EPP","S&D","EFDD",
"EPP","EFDD","GUE/NGL","EPP","Greens/EFA",
"ENF","Greens/EFA","EPP","S&D","ALDE","ALDE",
"S&D","EPP","Greens/EFA","S&D","EPP",
"ECR","GUE/NGL","EPP","GUE/NGL","S&D",
"EFDD"),
EP = c("EP8",
"EP8","EP8","EP8","EP8","EP8","EP8","EP8",
"EP8","EP8","EP8","EP8","EP8","EP8",
"EP8","EP8","EP8","EP8","EP8","EP8","EP8",
"EP8","EP8","EP8","EP8","EP8","EP8",
"EP8","EP8","EP8","EP8","EP8","EP8","EP8",
"EP8","EP8","EP8","EP8","EP8","EP8","EP8",
"EP8","EP8","EP8","EP8","EP8","EP8",
"EP8","EP8","EP8","EP8","EP8"),
value = c(-0.379774242996712,0.172315972440176,
0.508771375843188,0.735039922061224,-0.0293302188505968,
0.488793320045722,0.308600110879289,
-0.126657264650647,0.034159060407793,0.0978260034285467,
-0.121273309161861,-0.138765859773851,
0.636554976021266,-0.0512297661682134,
-0.108291772901163,-0.137474882596259,
0.237202866634456,0.0515686354827501,-0.633685137601414,
-0.138543322004933,0.229710312045323,
0.16976906020358,-0.124000426216816,-0.640680518772482,
0.632176298730038,0.182133291153883,
0.0597572759751731,0.300926182066494,
0.594026312274795,-0.0768024002434432,0.213015201862035,
-0.464690847421952,-0.130741159014226,
-0.141132931728519,0.359063454395183,
-0.484702695864316,0.472995183059961,0.249977354995377,
0.530843230444484,0.150692540827256,
0.188067474315055,0.476434445817727,0.218584627498155,
0.369565589855805,0.460152467874211,
0.411953625494457,-0.277238106259614,
-0.220648817516735,0.247530849978582,0.0345924579021892,
0.769167419206866,-0.544629742856372),
variable = as.factor(c("Dimension 1",
"Dimension 1","Dimension 1","Dimension 1",
"Dimension 1","Dimension 1",
"Dimension 1","Dimension 1","Dimension 1",
"Dimension 1","Dimension 1",
"Dimension 1","Dimension 1",
"Dimension 1","Dimension 1","Dimension 1",
"Dimension 1","Dimension 1",
"Dimension 1","Dimension 1","Dimension 1",
"Dimension 1","Dimension 1",
"Dimension 1","Dimension 1",
"Dimension 1","Dimension 2","Dimension 2",
"Dimension 2","Dimension 2",
"Dimension 2","Dimension 2","Dimension 2",
"Dimension 2","Dimension 2",
"Dimension 2","Dimension 2",
"Dimension 2","Dimension 2","Dimension 2",
"Dimension 2","Dimension 2",
"Dimension 2","Dimension 2","Dimension 2",
"Dimension 2","Dimension 2",
"Dimension 2","Dimension 2",
"Dimension 2","Dimension 2","Dimension 2"))
)
ggplot(plot8beta, aes(x=factor(EPG,levels=c("ENF","EFDD","Greens/EFA","GUE/NGL","ALDE","ECR","S&D","EPP")), y=value,colour=EPG)) +
geom_jitter(position=position_jitter(width=0.2,height=0),alpha=0.7)+
geom_boxplot(alpha=0,show.legend=FALSE,lwd=1)+
scale_color_manual(limits = c("EPP","S&D","ECR","ALDE","GUE/NGL","Greens/EFA","EFDD","ENF"),
values = c("#ffdb05","#fc1414","#106da8","#ec008c","#c6262c","#44911d","#00abbc","black")) +
guides(color=guide_legend(""))+
theme(legend.position="bottom",
axis.text.y=element_blank(),
axis.ticks=element_blank(),
text=element_text(size=13))+
labs(x="",y="",title="",subtitle=expression(paste("Figure 8: Ideal Position Estimated by IRT in the 8"^"th"*" European Parliament")))+
coord_flip()+
facet_grid(variable~.)
Do you have any advise?
Thank you!