0
我正面臨着使用ggplot在barplot上合併線圖的問題。酒吧情節很好,但是當我繪製線條時,它直接位於每年。我想在每個位置的第一個barplot「C」上劃線。組合圖:幾何條和點如何改變點在第一個barplot上的位置
感謝您的幫助!
tb3 <- structure(list(Year=c("2003","2005","2006","2007",
"2010","2012","2013",
"Before 2003","2003","2005",
"2006","2007","2010","2012",
"2013","Before 2003"),
tchtype=c("C","C","C","C","C","C",
"C","C","R","R","R","R",
"R","R","R","R"),
Freq=c(145,420,115,134,150,17,142,
33,5,3,25,23,4,134,2,237),
Local=c(140,393,46,29,26,2,15,2,
rep(NA,8))),
row.names=c(NA,-16L),
.Names=c("Year","tchtype","Freq",
"Local"),
class="data.frame")
ggplot(data=tb3, aes(x=Year, y=Freq)) +
geom_bar(aes(fill=tchtype, linetype=tchtype, color=tchtype,width=.8),
stat="identity", position='dodge') +
geom_text(aes(label=Freq,group=tchtype),
position=position_dodge(0.8), vjust = -1, size = 3) +
scale_color_manual(values = c("black","black")) +
scale_fill_brewer(type = 'div', palette = 'Greys', direction = -1) +
theme_bw() +
geom_line(aes(x=Year, y=Local, group=tchtype)) +
geom_point(aes(x=Year, y=Local, group=tchtype)) +
ylab(label="Number of teachers") +
xlab("Year of appointment") +
theme(legend.title=element_blank(),
legend.position=c(.75, .75))
我想你應該解決的第一件事就是 「在2003年之前」 的位置。 – neilfws