此問題與之前的post有關。如何將y軸更改爲對數比例?
說我有這組數據test
:
a b c
1 a x NA
2 b x 5.1e-03
3 c x 2.0e-01
4 d x 6.7e-05
5 e x NA
6 f y 6.2e-05
7 g y 1.0e-02
8 h y 2.5e-03
9 i y 9.8e-02
10 j y 8.7e-04
> dput(test)
structure(list(a = structure(1:10, .Label = c("a", "b", "c",
"d", "e", "f", "g", "h", "i", "j"), class = "factor"), b = structure(c(1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), .Label = c("x", "y"), class = "factor"),
c = c(NA, 0.0051, 0.2, 6.7e-05, NA, 6.2e-05, 0.01, 0.0025,
0.098, 0.00087)), .Names = c("a", "b", "c"), row.names = c(NA,
-10L), class = "data.frame")
與ggplot定期繪製它會給這個圖:
> ggplot(test, aes(fill=a,y=c,x=b)) +
geom_bar(position="dodge",stat="identity")
如何設置y軸作爲對數標度(例如,0,10 -6,10 -5, 10 -4 ... 10 ),因此如果不直接對數據進行對數轉換,條形的高度就不會太遠。另外,我該如何完成此操作,以便它仍將NA
值顯示爲圖中的零值?
我也嘗試了scale_y_log10()
函數,但條形從上到下。我希望他們不要那樣。
謝謝!
'P + scale_y_log10()' – Suren
您應就如何使可重複的例子https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-閱讀可重現的例子 – Suren
@DiscoSuperfly我試過了,但酒吧從上到下。我不知道如何繞過它。 – Dodong