在x_axis,ggplot2上将分组的箱线图起点更改为0

时间:2019-01-22 17:26:31

标签: r ggplot2 axis boxplot

我的第一组箱线图从0.5开始,但是我希望它们从0开始。有人可以帮忙添加对您有帮助的代码!谢谢

ggplot(box, aes(x = Species, y = risk.of.death, fill = Scenario)) +
  geom_boxplot(position = position_dodge(0.6), width = 0.5)  +
  scale_y_continuous(labels=scales::percent, breaks = seq(0, 1.0 , 0.1), 
                     expand = c(-0, 0), 
                     limits = c(min(box[, 'risk.of.death']), 
                                max(box[, "risk.of.death"]) + 0.05)) +
  expand_limits(x = 0, y = 0) +
  theme(axis.text.x = element_text(angle = 90)) +
  xlab('Species of Tree')+ 
  ylab('Population Risk of Mortality (%)') +
  theme(axis.text.x = element_text(angle = 90), 
        panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.background = element_blank(),
        axis.line = element_line(colour = "black"),
        plot.margin = unit(c(1, 1, 1.5, 1.2), "cm")) +

dput(box)

Figure that the code produces,but I want to shift everything closer to the y axis so the sections are evenly spaced

0 个答案:

没有答案