当前位置:网站首页>Function summary of drawing object arrangement in R language
Function summary of drawing object arrangement in R language
2022-04-23 15:53:00 【zoujiahui_ two thousand and eighteen】
List of articles
par(mfrow=c(n,m)) Basic mapping
par(mfrowc(n,m)) yes R Functions in basic drawing , Only basic mapping functions plot Objects that work
gridExtra::grid.arrange() in the light of ggplot object
grid.arrange() Function can only be used on ggplot Arrange objects
usage
# All parameters
grid.arrange(..., grobs = list(...), layout_matrix, vp = NULL,
name = "arrange", as.table = TRUE, respect = FALSE, clip = "off",
nrow = NULL, ncol = NULL, widths = NULL, heights = NULL, top = NULL,
bottom = NULL, left = NULL, right = NULL, padding = unit(0.5, "line"),newpage=TRUE)
# Common formats
grid.arrange(p1,p2,p3,...,ncol=n,nrow=m)
example
library(gridExtra)
library(ggplot2)
p1=qplot(1:10, rnorm(10), main=paste("plot", 1))
p2=qplot(1:10, rnorm(10), main=paste("plot", 2))
p3=qplot(1:10, rnorm(10), main=paste("plot", 3))
grid.arrange(p1,p2,p3,nrow=2,ncol=2)
ggpubr::ggarrange() Treatable ggplot Object and foundation plot object
usage
ggarrange(
...,
plotlist = NULL,
ncol = NULL,
nrow = NULL,
labels = NULL,
label.x = 0,
label.y = 1,
hjust = -0.5,
vjust = 1.5,
font.label = list(size = 14, color = "black", face = "bold", family = NULL),
align = c("none", "h", "v", "hv"),
widths = 1,
heights = 1,
legend = NULL,
common.legend = FALSE,
legend.grob = NULL
)
example
library(ggplot2)
library(ggpubr)
data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)
bxp <- ggboxplot(df, x = "dose", y = "len",
color = "dose", palette = "jco")
dp <- ggdotplot(df, x = "dose", y = "len",
color = "dose", palette = "jco")
dens <- ggdensity(df, x = "len", fill = "dose", palette = "jco")
plt<- ~{
par(
mar = c(3, 3, 1, 1),
mgp = c(2, 1, 0)
)
plot(sqrt)
}
# Arrange
# ::::::::::::::::::::::::::::::::::::::::::::::::::
ggarrange(bxp, dp,dens,plt, ncol = 2, nrow = 2)
cowplot::plot_grid() Can be used for different objects
usage
plot_grid(
...,
plotlist = NULL,
align = c("none", "h", "v", "hv"),
axis = c("none", "l", "r", "t", "b", "lr", "tb", "tblr"),
nrow = NULL,
ncol = NULL,
rel_widths = 1,
rel_heights = 1,
labels = NULL,
label_size = 14,
label_fontfamily = NULL,
label_fontface = "bold",
label_colour = NULL,
label_x = 0,
label_y = 1,
hjust = -0.5,
vjust = 1.5,
scale = 1,
greedy = TRUE,
byrow = TRUE,
cols = NULL,
rows = NULL
)
example
library(ggplot2)
library(cowplot)
df <- data.frame(
x = 1:10, y1 = 1:10, y2 = (1:10)^2, y3 = (1:10)^3, y4 = (1:10)^4
)
p1 <- ggplot(df, aes(x, y1)) + geom_point()
p2 <- ggplot(df, aes(x, y2)) + geom_point()
p6 <- ~{
par(
mar = c(3, 3, 1, 1),
mgp = c(2, 1, 0)
)
plot(sqrt)
}
p7 <- function() {
par(
mar = c(2, 2, 1, 1),
mgp = c(2, 1, 0)
)
image(volcano)
}
# ggarrange(p1,p2,p3,p4)
# making rows and columns of different widths/heights
plot_grid(
p1, p2,p6,p7, nrow = 2,ncol=2,rel_heights = c(2,1), rel_widths = c(1, 2),labels = "AUTO",scale = c(1, .5, .9, .7)
)
#' # missing plots in some grid locations, auto-generate lower-case labels
plot_grid(
p1, NULL, NULL, p6, p7, NULL,
ncol = 2,
labels = "auto",
label_size = 12,
align = "v"
)
customLayout::lay_new() More powerful and flexible
To be continued …
版权声明
本文为[zoujiahui_ two thousand and eighteen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231547288840.html
边栏推荐
- WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
- Merging of Shanzhai version [i]
- 王启亨谈Web3.0与价值互联网“通证交换”
- 幂等性的处理
- s16. One click installation of containerd script based on image warehouse
- Mobile finance (for personal use)
- 多级缓存使用
- dlopen/dlsym/dlclose的简单用法
- s16.基于镜像仓库一键安装containerd脚本
- 基于 TiDB 的 Apache APISIX 高可用配置中心的最佳实践
猜你喜欢
Groupby use of spark operator
cadence SPB17. 4 - Active Class and Subclass
Redis master-slave replication process
mysql乐观锁解决并发冲突
一文读懂串口及各种电平信号含义
pgpool-II 4.3 中文手册 - 入门教程
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
C, calculation method and source program of bell number
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
大厂技术实现 | 行业解决方案系列教程
随机推荐
Config learning notes component
为啥禁用外键约束
Partitionby of spark operator
5分钟,把你的Excel变成在线数据库,神奇的魔方网表excel数据库
Config组件学习笔记
北京某信护网蓝队面试题目
Spark 算子之partitionBy
Large factory technology implementation | industry solution series tutorials
Sortby use of spark operator
【开源工具分享】单片机调试助手(示波/改值/日志) - LinkScope
Multi level cache usage
Coalesce and repartition of spark operators
王启亨谈Web3.0与价值互联网“通证交换”
Upgrade MySQL 5.1 to 5.68
【自娱自乐】构造笔记 week 2
腾讯Offer已拿,这99道算法高频面试题别漏了,80%都败在算法上
多线程原理和常用方法以及Thread和Runnable的区别
PS add texture to picture
R语言中实现作图对象排列的函数总结
MySQL集群模式與應用場景