我正在使用 layout() 在 R 中创建一个多图图形,并且只希望 y 轴显示在底部图中。因此,我将它们从循环中取出并将它们与轴一起添加到下方,但是当我这样做时,它们会被切断。这是我正在使用的代码:
onlytext <- function(string){
plot(0:1, 0:1, bty='n', type='n', xaxt='n', yaxt='n', xlab='', ylab='')
text(0.5, 0.5, string, cex=1.2, font=2)
}
nf <- layout(matrix(c(0,1:14), 5, 3, byrow=TRUE), heights = c(2,5,5,5,5), widths = c(1.5,4,4))
par (mar=c(.3,.3,.3,.3))
onlytext ('Approval'); onlytext ('Vote Choice')
name_vec <- c("Strongly Approve", "Approve", "Disapprove", "Strongly Disapprove")
control_means_tab <- matrix(sample(rnorm(100), 48), ncol = 6, nrow = 4)
x <- seq(1,6)
for(i in 1:3){
onlytext(name_vec[i])
for(j in 1:2){
plot(x, control_means_tab[j,], xaxt = 'n', xlab = '', ylab = '', xaxt='n', bty = "n", ylim = c((min(c(control_means_tab, scorecard_means_tab, endorsement_means_tab))- .02),(max(c(control_means_tab, scorecard_means_tab, endorsement_means_tab)) + .02)), col = "blue", pch = 19, cex =.6)
}
}
onlytext(name_vec[4])
plot(x, control_means_tab[j,], xlab = '', ylab = '', xaxt = "n", bty = "n", ylim = c((min(c(control_means_tab, scorecard_means_tab, endorsement_means_tab))- .02),(max(c(control_means_tab, scorecard_means_tab, endorsement_means_tab)) + .02)), col = "blue", pch = 19, cex =.6)
axis(1, 1:6, LETTERS[1:6])
plot(x, control_means_tab[j,], xaxt = 'n', xlab = '', ylab = '', xaxt='n', bty = "n", ylim = c((min(c(control_means_tab, scorecard_means_tab, endorsement_means_tab))- .02),(max(c(control_means_tab, scorecard_means_tab, endorsement_means_tab)) + .02)), col = "blue", pch = 19, cex =.6)
axis(1, 1:6, LETTERS[1:6])
任何关于如何恢复该轴的想法都值得赞赏!