在组合条形图中调整1个图边距?

时间:2018-07-09 23:19:42

标签: r

我正在尝试调整组合图中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)

R Output Image

0 个答案:

没有答案