r - 在 R 中自动绘制 x 个图形
问题描述
我想生成一个函数来自动绘制 x 个数字(没有 ggplot),我的图如下(它们没有达到我的预期,它们太大并且不适合 par 函数的行或列):
chess_games<-read.csv("./data/games.csv")
chess_games_rated<-table(chess_games$rated)
head (chess_games_rated)
bp.1<-barplot(chess_games_rated, cex.lab=1.5, cex.axis=1.2, font=1)
chess_games<-read.csv("./data/games.csv")
chess_games_rated<-table(chess_games$winner, chess_games$rated)
bp.3<-barplot(chess_games_rated, col=c("blue","red","green"), cex.axis=1.5)
bp.4<-legend(x="topleft", legend = levels(df.1$winner), col=c("blue","red","green"), pch=19, cex=1, pt.cex = 1)
bp.2<-c(bp.3, bp.4)
boxplot.1<-boxplot(cream_rating ~ victory_status, chess_games[!chess_games$winner %in% "draw", ], cex.axis=1.2)
par(mai=rep(0.5, 4))
layout(matrix(c(1,1, 2,2, 0, 3,3, 0), ncol = 4, byrow = TRUE))
bp.1
bp.2
boxplot.1
我的数据是:
A data.frame: 6 × 8
rated turns victory_status winner increment_code cream_rating charcoal_rating opening_name
<lgl> <int> <fct> <fct> <fct> <int> <int> <fct>
1 FALSE 13 outoftime cream 15+2 1500 1191 Slav Defense: Exchange Variation
2 TRUE 16 resign charcoal 5+10 1322 1261 Nimzowitsch Defense: Kennedy Variation
3 TRUE 61 mate cream 5+10 1496 1500 King's Pawn Game: Leonardis Variation
4 TRUE 61 mate cream 20+0 1439 1454 Queen's Pawn Game: Zukertort Variation
5 TRUE 95 mate cream 30+3 1523 1469 Philidor Defense
6 FALSE 5 draw draw 10+0 1250 1002
我试过这个:
rowplot<-function(x,y,z) {par(mfrow=c(1,3)) (layout(matrix(c(1,1, 2,2, 0, 3,3, 0), ncol = 4, byrow = TRUE)))}
rowplot(bp.1,bp.2,boxplot.1)
但它什么也不返回。
解决方案
推荐阅读
- c# - 如何为需要来回转换的泛型方法创建委托
- javascript - 如何循环此函数以使动画无限重复?
- symfony - Is there a way to show all Sylius products in one view?
- javascript - 如何为电子邮件输入制作一个自动显示@domain.com 的输入组件
- xamarin - 无法使用 Xamarin Prism 7.1 在部分视图中设置绑定到 BindableProperties
- python - 如何将 Python ZMQ 链接到标准 UDP 或 TCP 服务器(旧版,使用 C++ 编写 ~ 15 年前)
- c++ - 使用没有堆内存分配的接口的框架应用程序?
- r - 如何创建 dyad pair 变量?
- python - 调试器说我的变量没有定义,但我在函数中用 return() 买了它
- javascript - 如何使蹦床适应延续传球风格?