通常,vjsust = 用最大值y值調整標簽距離,當sd不同時,這并不漂亮,是否可以用上誤差條的相等相對距離來調整它?
在下面的例子中,aandb應該上下移動c,如何繪制呢?
df <- data.frame(dose=c("D0.5", "D1", "D2"),
len=c(4.2, 10, 29.5), sd = c(0.2, 2, 5),
label = c('a', 'b', 'c'))
ggplot(df, aes(x = dose, y = len))
geom_errorbar(aes(ymin = len, ymax = len sd), width=.1, position=position_dodge(.6))
geom_bar(position = position_dodge(), stat="identity", width=.4)
geom_text(aes(label = label, angle = 0),vjust = -2.5)

uj5u.com熱心網友回復:
使用aestethics 中的y引數根據誤差線設定標簽的位置:geom_text
ggplot(df, aes(x = dose, y = len))
geom_errorbar(aes(ymin = len, ymax = len sd), width=.1, position=position_dodge(.6))
geom_bar(position = position_dodge(), stat="identity", width=.4)
geom_text(aes(y = len sd, label = label, angle = 0),vjust = -2.5)
ylim(0, 40)

轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/427641.html
