我正在使用R创建一些箱图。
这是我的代码:
fps_error <- c(0.033872847, 0.041710742,0.023839866,0.017763328,0.044510719,0.016390502,0.056766647,0.101326807,0.013990558,0.014848592)
fps_error = fps_error *100
fps_qp_error <-c(1.631578947, 2.263157895, 1.45, 1.2, 2.388888889, 1.05, 1.764705882, 4.642857143, 0.95, 1.047619048)
bit_error <- c(0.113818414,0.17059614, 0.110048539, 0.030207725, 0.157858064, 0.031467476, 0.258009778, 0.220182593, 0, 0.030935528)
bit_error = bit_error *100
bit_qp_error <-c(0.65, 0.80952381, 0.523809524, 0.142857143, 0.904761905, 0.142857143, 1.473684211, 1.047619048, 0, 0.19047619)
ssim_error <-c(0.012973075, 0.006374072, 0.003292312, 0.003139452, 0.009791549,0.008385301, 0.003566528, 0.00986248, 0.003586361, 0.003680912)
ssim_error = ssim_error * 100
ssim_qp_error <-c(3.476190476, 0.944444444, 0.7, 0.65, 2.095238095, 1.470588235, 0.75, 1.529411765, 0.736842105, 0.8)
all_errors = cbind(fps_error, bit_error, ssim_error)
all_qp_errors = cbind(fps_qp_error, bit_qp_error, ssim_qp_error)
modes = cbind(rep("FPS error",10), rep("Bitrate error",10), rep("SSIM error",10))
#Version 2
journal_linear_data <-data.frame(fps_error, fps_qp_error,bit_error,bit_qp_error,ssim_error,ssim_qp_error )
yvars <- c("fps_error","bit_error","ssim_error")
xvars <- c("FPS", "Bitrate", "SSIM")
graphics.off()
op <- par(mfrow = c(1, 3), #matrix of plots
oma = c(0,0,2,0)) #outer margins
par(cex.lab=2.5)
par(cex.axis=2.5)
for (i in 1:3) {boxplot(journal_linear_data[,yvars[i]], xlab=xvars[i], ylab="% error")}
par(op)
mtext(text="Percentage error per mode for B2",side=3, line=1.5, font=2, cex=2, col='black')
从下图中可以看出,y标签部分隐藏。你知道怎么解决这个问题吗?
答案 0 :(得分:1)
将通话中的保证金更改为par()
:
op <- par(mfrow = c(1, 3), #matrix of plots
oma = c(0,0,2,0),#outer margins
mar=c(5.1, 5.1, 4.1, 2.1) #inner margins
)