R ggplot,geom_text用于标签命令中的圆形标签?

时间:2018-05-09 17:06:31

标签: r ggplot2 geom-bar geom-text

现在我可以通过ggplot geom_bar中的条形获得上面填充值的标签。但我似乎无法改变标签的小数位数。现在它有9个小数位,我只想要2.我尝试使用round()和digits =失败。我不知道在我的代码中将它们放在哪里。

比例是我想要标记的只有2位小数

谢谢!

PaperMazeProportion <- ggplot(PM_df, aes(factor(OrientationNum), Proportion, fill=Choice)) +
  stat_summary(fun.y = mean, geom = "bar", position = "dodge") +
  labs(x= "Orientation of Maze",
       title = "Paper Maze Path Choice Penn State; May 07, 2018") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_y_continuous(limits= c(0, 0.65)) +
  scale_x_discrete(labels=c("North-South", "South-North", "East-West", "West-East"), breaks=c("1", "2", "3", "4")) +
  geom_text(aes(label=Proportion), position=position_dodge(width=0.9), digits=1, vjust=-0.25, size=3)

0 个答案:

没有答案