码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • R语言快速实现图片布局(1)


    (1)简单的一排或者对称的多排,使用patchwork即可。/表示分行,|表示分列

    1. library(patchwork)
    2. pp1<-ggplot(mtcars) + geom_point(aes(mpg, disp))
    3. pp2<-ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear))
    4. pp3 <- ggplot(mtcars) + geom_bar(aes(gear)) + facet_wrap(~cyl)
    5. pp1 /((pp2|pp3) +plot_layout(ncol = 2,#1列
    6. guides='collect'))+
    7. plot_annotation(tag_levels = c('A', '1'))+#标注A\B\C
    8. #plot_annotation(tag_levels = list(c('&', '%'), '1'))#标注特殊符号

    (2)使用customLayout包:可以实现自由设定画布分布。

    1. #创建画布
    2. library(customLayout)
    3. help(package="customLayout")
    4. lay1 <- lay_new(matrix(1:6, nr = 3), widths = c(3,3),heights = c(3,3,3))
    5. lay2 <- lay_new(matrix(1, nr = 1), widths = c(1),heights = c(9))
    6. #合并
    7. slay1<-lay_bind_col(lay1,lay2,widths = c(2,1))
    8. lay_show(slay1)
    9. #拆分
    10. l1 <- lay_new(matrix(c(1:4), ncol = 2), widths = c(4, 1))
    11. l2 <- lay_new(matrix(c(1:4), ncol = 2), widths = c(1, 1))
    12. l3 <- lay_split_field(l1, l2, 2)
    13. lay_show(l2)
    14. #填充图形
    15. #plot直接绘制即可
    16. #ggplot需要使用list
    17. library(ggplot2)
    18. l1 <- lay_new(matrix(1:2, ncol = 1), heights = c(2, 3))
    19. l2 <- lay_new(matrix(1:2, ncol = 1), heights = c(1, 3))
    20. l3 <- lay_bind_col(l1, l2)
    21. pl1 <- qplot(mpg, wt, data = mtcars)
    22. pl2 <- qplot(mpg, gear, data = mtcars)
    23. pl3 <- qplot(cyl, gear, data = mtcars)
    24. pl4 <- qplot(qsec, am, data = mtcars)
    25. lay_grid(list(pl1, pl2, pl3, pl4), l3)

  • 相关阅读:
    REACT
    9. SAP ABAP OData 服务如何支持删除(Delete)操作
    Jmeter基础(3) 发起一次请求
    odoo14 生成PDF报表详解
    vuejs - - - - - 使用code编辑器codemirror
    渡众机器人自动驾驶小车运行Autoware 实现港口物流运输
    【微信小程序开发】史上最详细的入门教学
    记录一次时序数据库的实战测试
    微信小程序获取剪切板的内容到输入框中
    Linux之高级文件系统管理
  • 原文地址:https://blog.csdn.net/weixin_49320263/article/details/133656431
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号