此问题与之前的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