美文网首页ggplot2绘图R小白相关
R可视化:拼图代码暂存

R可视化:拼图代码暂存

作者: 生信学习者2 | 来源:发表于2024-03-10 15:51 被阅读0次
library(ggplot2)
library(patchwork)

# Setup common theme elements for all the plots
theme_set(
  theme_bw() +
    theme(
      plot.subtitle = element_text(face = "bold")
    )
)

#------------------------------------------------------------------------------*
# Plot 1
#------------------------------------------------------------------------------*
ggplot(mtcars) +
  geom_point( aes(disp, mpg, color = factor(cyl)), show.legend = FALSE ) +
  labs(
    title = paste(
      "Figure 1: Relations between fuel displacement,",
      "horsepower and fuel efficiency."
    ),
    subtitle = "A", caption = "Some inconspicuous text."
  ) +
  theme(plot.caption = element_text(hjust = 0)) +
  { # <--- nested plots
    #--------------------------------------------------------------------------*
    # Plot 2
    #--------------------------------------------------------------------------*
    ggplot(mtcars) +
      geom_point(aes(disp, hp, color = factor(cyl))) +
      # Individual plot annotations
      labs(subtitle = "B") +
      # Spacing
      patchwork::plot_spacer() +
      { # <--- nested plots
        #----------------------------------------------------------------------*
        # Plot 3
        #----------------------------------------------------------------------*
        ggplot(mtcars) +
          geom_point( aes(hp, mpg, color = factor(cyl)), show.legend = FALSE ) +
          # Individual plot annotations
          labs(subtitle = "C")
      } +
      patchwork::plot_layout(ncol = 1)
  } +
  patchwork::plot_layout(ncol = 2, widths = c(2.2, 1))

相关文章

  • Part 5:R语言作图

    1.常用可视化R包 作图baseggplot2ggpubr 拼图par里mfrowgrid.arragecowpl...

  • 03-08

    06 R语言作图 图就是数据,数据就是图 常用可视化R包 作图:base,ggplot2, ggpubr;拼图:p...

  • 暂存代码

    Flutter 获取图片像素数据(rgba) quick app flex basis 测试 & 根节点最小高度不...

  • Git 简明手册

    1. 代码仓库及工作区: 工作区 working directory 暂存区 staging area 仓库区 r...

  • R语言之可视化①④一页多图(1)

    目录 R语言之可视化①误差棒 R语言之可视化②点图 R语言之可视化③点图续 R语言之可视化④点韦恩图upsetR ...

  • R语言之可视化⑥R图形系统续

    目录 R语言之可视化①误差棒 R语言之可视化②点图 R语言之可视化③点图续 R语言之可视化④点韦恩图upsetR ...

  • R语言之可视化⑩坐标系统

    目录 R语言之可视化①误差棒 R语言之可视化②点图 R语言之可视化③点图续 R语言之可视化④点韦恩图upsetR ...

  • R语言之可视化⑨火山图

    目录 R语言之可视化①误差棒 R语言之可视化②点图 R语言之可视化③点图续 R语言之可视化④点韦恩图upsetR ...

  • R语言之可视化⑦easyGgplot2散点图

    目录 R语言之可视化①误差棒 R语言之可视化②点图 R语言之可视化③点图续 R语言之可视化④点韦恩图upsetR ...

  • R语言之可视化⑧easyGgplot2散点图续

    目录 R语言之可视化①误差棒 R语言之可视化②点图 R语言之可视化③点图续 R语言之可视化④点韦恩图upsetR ...

网友评论

    本文标题:R可视化:拼图代码暂存

    本文链接:https://www.haomeiwen.com/subject/hlspzdtx.html