R语言绘图-拼图
Posted 生信小猪
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了R语言绘图-拼图相关的知识,希望对你有一定的参考价值。
customLayout包
"customLayout") install.packages(
library(customLayout)
#创建分割:lay_new()
行拼接:lay_bind_row()
列拼接:lay_bind_col()
嵌套:lay_split_field()
预览当前布局:lay_show()
设定分割结果:lay_set()
#customLayout:利用矩阵对画布进行分隔,绘图顺序按数字的大小,依次绘图
lay1 <- lay_new(
matrix(c(2,3,4,1), ncol = 2,byrow = T),
widths = c(3, 2), #指定宽度3和2
heights = c(2, 1)) #指定高度2和1
lay_show(lay1)
lay1 <- lay_new(
matrix(c(2,3,4,1), ncol = 2,byrow = T),
widths = c(3, 2),
heights = c(2, 1))
lay2 <- lay_new(
matrix(1:4, ncol = 2),
widths = c(3, 5),
heights = c(2, 4))
#按列合并画布
cl1 <- lay_bind_col(lay1, lay2, widths = c(3, 1))
lay_show(cl1)
lay1 <- lay_new(
matrix(c(2,3,4,1), ncol = 2,byrow = T),
widths = c(3, 2),
heights = c(2, 1))
lay2 <- lay_new(
matrix(1:4, ncol = 2),
widths = c(3, 5),
heights = c(2, 4))
#按行合并画布
cl2 <- lay_bind_row(lay1, lay2, heights = c(5, 2))
lay_show(cl2)
lay1 <- lay_new(
matrix(c(2,3,4,1), ncol = 2,byrow = T),
widths = c(3, 2),
heights = c(2, 1))
lay2 <- lay_new(
matrix(1:4, ncol = 2),
widths = c(3, 5),
heights = c(2, 4))
#分割画布嵌入
slay <- lay_split_field(lay1, lay2, field = 2) #在lay1的基础上,对lay1中的2模块,按lay2的原则进行分割
lay_show(slay)
lay1 <- lay_new(
matrix(c(2,3,4,1), ncol = 2,byrow = T),
widths = c(3, 2),
heights = c(2, 1))
lay2 <- lay_new(
matrix(1:4, ncol = 2),
widths = c(3, 5),
heights = c(2, 4))
#分割画布嵌入
slay <- lay_split_field(lay1, lay2, field = 2) #在lay1的基础上,对lay1中的2模块,按lay2的原则进行分割
lay_show(slay)
library(RColorBrewer)
palette(brewer.pal(8,"Set2"))
# 设定绘图对象布局
set.seed(100)# 绘图填充
plot(1:100 + rnorm(100),col="blue") # 填充到画布第1格
plot(rnorm(100), type = "l",lty=3,col="blue") # 填充到画布第2格
hist(rnorm(500),col=rainbow(7),yaxs='i')
box(bty="l")
plot(density(rnorm(100)),col="blue") # 填充到画布第4格
pie(c(30, 44, 64), col = 2:4)
pie(c(34, 24, 74), col = 2:4 + 3)
pie(c(54, 44, 24), col = 2:4 + 6)
以上是关于R语言绘图-拼图的主要内容,如果未能解决你的问题,请参考以下文章