我正在對課程評估進行圖形分析。 我得到了以下數據:添加第二個沒有對應x數據的y軸
> str(dataJ2)
'data.frame': 16 obs. of 22 variables:
...
$ lk_nummer : Factor w/ 111 levels "051-0311-00S",..: 19 30 38 47 49 50 51 55 56 59 ...
$ le_titel : Factor w/ 111 levels "","Advanced Methods and Strategies in Synthesis",..: 6 99 75 82 84 8 40 39 38 68 ...
$ anzahl_stud : int 7 79 1 34 10 20 83 10 4 11 ...
$ durchschnitt : num 4.61 5.35 3.5 4.4 4.4 4.33 4.49 4.53 5.38 4.48 ...
$ standardabweich : num 0.4 0.54 0 1.02 1.21 0.62 1.17 0.9 0.28 0.68 ...
...
$ prozent_best : num 85.7 97.5 0 70.6 90 80 73.5 90 100 81.8 ...
...
使用GGPLOT2我能夠做圖看起來像這樣:
plotJ2 <- ggplot(dataJ2, aes(y=durchschnitt,x=le_titel))
plotJ2 + geom_bar(position=position_dodge(), stat="identity", fill = I("chartreuse4")) +
scale_y_continuous(limits=c(0,6.6),breaks=seq(from=1, to=6, by=1)) +
geom_errorbar(aes(ymin=durchschnitt-standardabweich, ymax=durchschnitt+standardabweich), width=.1) +
ggtitle("2. Jahr Bsc Biologie") +
ylab("Durchschnitt") + xlab("Fächer") +
geom_text(aes(label = durchschnitt, y = 1.8), size = 4, colour="gray85") +
geom_text(aes(label = anzahl_stud, y = 0.2), size = 4, colour="grey85") +
geom_text(aes(label = prozent_best, y = 6.55), size = 4, colour="chartreuse4", adj=1) +
geom_text(aes(label = "%", y = 6.6), size = 4, colour="chartreuse4", adj=0) +
coord_flip()
但然而,「 prozent_best「在圖形部分看起來不是很好。 我試圖用多行文字,文本和facet_wrap從「dataJ2 $ prozent_best」爲灰色圖形部分的右側的第二y軸的標籤,將數據添加,但不能使它工作。
有什麼建議嗎?
有用的翻譯數據註解/描述:
lk_nummer - >講座的數量
le_titel - >講座的名稱
anzahl_stud - >學生人數
durchschnitt - >平均值
prozent_best - > number of s它通過了考試百分比
Fächertudents - >類
使用不同的主題和左對齊? – Axeman
我會做這樣的事情:http://stackoverflow.com/a/17493256/471093 – baptiste
或者,定義更緊的x xlimits,但關閉gtable面板的裁減 – baptiste