2016-03-04 96 views
-1

我使用R創建一些箱型圖。R:在boxplot中更改y軸縮放比例

這裏是我的代碼:

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_qp_error <-c(3.476190476, 0.944444444, 0.7, 0.65, 2.095238095, 1.470588235, 0.75, 1.529411765, 0.736842105, 0.8) 
ssim_qp_error = ssim_qp_error *100 

all_errors = cbind(fps_error, bit_error, ssim_error) 
modes = cbind(rep("FPS error",10), rep("Bitrate error",10), rep("SSIM error",10)) 

journal_linear_data <-data.frame(fps_error, fps_qp_error,bit_error,bit_qp_error,ssim_error,ssim_qp_error) 

bp = boxplot(all_errors~modes, data=journal_linear_data, main="Percentage error per mode for B2", xlab="Mode", ylab="% error") 

這是造成圖像。 enter image description here

我想改變Y軸的比例,以顯示所有的boxlots足夠公平。例如。對於SSIM錯誤,我看不到錯誤。

+0

你可以用'ylim',但它不會告訴你所有你想要的youur SSIM誤差值太小的細節。 SSIM誤差方差(與其他兩個相比)太小。 – rbm

+0

剛剛用ylim = c(-10,30)運行你的代碼,這增加了規模,但是@rbm指出,這不是你想要的。 – user1945827

+0

y軸可能有不相等的步長嗎? – zinon

回答

1
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") 

graphics.off() 

op <- par(mfrow = c(1, 3), #matrix of plots 
      oma = c(0,0,3,0)) #outer margins 

for (i in 1:3) {boxplot(journal_linear_data[,yvars[i]], xlab=yvars[i], ylab="% error")} 

par(op) 

mtext(text="Percentage error per mode for B2",side=3, line=1.5, font=2, cex=2, col='black') 

See plot here

+0

這是一個公平的解決方案!謝謝!所有圖形有可能具有相同的x軸和y軸嗎? – zinon

+0

如果我想增加x和y標籤的大小,我該怎麼辦? – zinon

+0

我在for循環之前發現瞭解決方案'par(cex.lab = 2.5) par(cex.axis = 2.5)',但現在y標籤部分隱藏。你知道如何解決這個問題嗎? – zinon

相關問題