当前位置:   article > 正文

R语言ggplot2可视化自定义图例的位置实战:legend position、相对于绘图区域配置自定义图例位置_ggplot2 legend.position

ggplot2 legend.position

R语言ggplot2可视化自定义图例的位置实战:legend position、相对于绘图区域配置自定义图例位置

#相对于绘图区域配置自定义图例位置

  1. mtcars$cyl <- factor(mtcars$cyl, labels=c("four","six","eight"))
  2. library(gridExtra)
  3. a <- ggplot(mtcars, aes(x=wt, y=mpg, colour=cyl)) + geom_point(aes(colour=cyl)) + labs(title = "Legend is top left") +
  4. theme(legend.justification = c(0, 1), legend.position = c(0, 1))
  5. b <- ggplot(mtcars, aes(x=wt, y=mpg, colour=cyl)) + geom_point(aes(colour=cyl)) + labs(title = "Legend is bottom right") +
  6. theme(legend.justification = c(1, 0), legend.position = c(1, 0))
  7. c <- ggplot(mtcars, aes(x=wt, y=mpg, colour=cyl)) + geom_point(aes(colour=cyl)) + labs(title = "Legend is bottom left") +
  8. theme(legend.justification = c(0, 0), legend.position = c(0, 0))
  9. d <- ggplot(mtcars, aes(x
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/66004
推荐阅读
相关标签
  

闽ICP备14008679号