r - 在组合条形图中调整 1 个绘图边距?
问题描述
我正在尝试调整组合图中 1 个图的边距,以便完全显示图例。我尝试增加左侧的 par(mar= 并且它没有改变任何东西!第二个和第三个图共享相同的图例,所以我可以以某种方式减少图 2 和图 3 之间的边距,或者增加图的右边距3 所以传说显示?
这是我的代码:
par(mfrow= c(1,3))
par(mar=c(1.1, 1.1, 4.1, 8.8), xpd=TRUE) #margin lines
par(pin=c(1,2.8)) # plot areas for graphs
#graph 1
Cmatrix<- matrix(c(2.1, 1.9, 12.4, 12.7, 70.2), nrow=5, ncol=1)
rownames(Cmatrix)<- c("NA", "Never", "1-2 Times", "Monthly", "Weekly")
Cgraph<- barplot(Cmatrix,
ylab= "Cumulative Percentage",
main= "Collaboration",
ylim= c(0,100),
legend.text=T,
args.legend=list(x=5.9, y=105, bty = "n"),
space=4)
#graph 2
par(mar=c(1.1, 1.1, 4.1, 0), xpd=TRUE) #margin lines
par(pin=c(1,2.8)) # plot areas for graphs
DRmatrix<- matrix(c(1.8, 1.4, 2.5, 4.8, 16.9, 43.3, 29.4), nrow=7, ncol=1)
rownames(DRmatrix)<- c("NA", "Strongly Disagree", "Disagree", "Somewhat Disagree", "Somewhat Agree", "Agree", "Strongly Agree")
DRgraph<- barplot(DRmatrix,
xlab="Student Response",
main= "Discovery & Relevance",
ylim= c(0,100))
#legend.text=T,
#args.legend=list(x=6, y=105, bty = "n"),
#space=0)
#graph 3
par(mar=c(1.1, 0, 4.1, 20.1), xpd=TRUE) #margin lines
par(pin=c(1,2.8)) # plot areas for graphs
Imatrix<- matrix(c(2.2, 1.6, 5.4, 11.8, 18.9, 38, 22.1), nrow=7, ncol=1)
rownames(Imatrix)<- c("NA", "Strongly Disagree", "Disagree", "Somewhat Disagree", "Somewhat Agree", "Agree", "Strongly Agree")
Igraph<- barplot(Imatrix,
main= "Iteration",
ylim= c(0,100),
legend.text=T,
args.legend=list(x=6.9, y=105, bty = "n"),
space=4.5)
mtext("Average Student Responses to the LCAS Survey Categories", side = 3, line = -3, outer = TRUE)
解决方案
推荐阅读
- javascript - Next.js TypeError:无法读取未定义的属性(读取“集合”)
- python - soup.find 找不到 HTML 路径并返回“无”,但该路径确实存在。有谁知道我哪里出错了?
- android - 如何在jetpack compose中隐藏导航栏和状态栏?
- getstream-io - 将用户提要添加到他自己的时间线的最佳方法是什么?
- javascript - 我们可以通过多少种方式将 props 传递给 react 中的所有子组件
- android - 在应用程序购买的移动应用程序中,我如何在重新安装应用程序时发现用户已付费?
- r - 如何在 R 中为 .data 格式创建时间序列?
- asp.net - 使用 NSwag 生成多个 OpenAPI 文档
- python - 从另一个 DataFrame 中查找并计算一个 DataFrame 的元素数
- arrays - 从数组到对象并创建子类