簡體   English   中英

如何在X軸圖中不忽略NA值? [R]

[英]How to not omit NA values in x-axis plot? [R]

我正在嘗試繪制將三個圖形合並在一起的圖。 (請參見下面的圖)

所有這三個值的x值都在0.0到1.0之間變化。 但是,只有其值真正接近最終x值(1.0)的圖才具有整個x軸范圍。

查看函數axis(),我看到“省略了非限定(無限,NaN或NA)值”,因此有意義的是,沒有1.0左右值的繪圖將沒有等效的x軸。

首先,我認為可能是因為它們的大小,但是即使從繪圖中減小CEX,X軸也將保持不變。

我該如何解決這種情況? 我真的希望所有三個圖形都具有整個x軸,且在0.0-1.0之間變化。

我使用的腳本是基本的axis()函數,例如:axis(1,c(0.0,0.2,0.4,0.6,0.8,1.0))

整個代碼(有點混亂,抱歉):

 t = c(0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360) p = c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0) par(mfrow=c(1,3)) par(mar= c(5.1, 5, 3, 0)) plot (Pertinencia_Cluster_1, prof, axes = FALSE, type = 'n', xlab = '', ylab = 'Profundidade (m)', cex.main = 0.8) # rect(0, 153, 4, 190, col = '#fffae6', border = "#fffae6") # rect(0, 203, 4, 248, col = '#fffae6', border = "#fffae6") axis(1, p) axis(2, t) grid() lines(Pertinencia_Cluster_1, prof, col = '#cc0000', pch = 16, cex = 0.8) points(Pertinencia_Cluster_1, prof, col = '#cc0000', pch = 16, cex = 0.8) legend(0.12, -25, xpd = TRUE, legend = "Pertinência Cluster 1", pch = 16, col = "#cc0000", cex = 1.0) par(mar= c(5.1, 2.5, 3, 2.5)) plot (Pertinencia_Cluster_2, prof, col = "#008B8B", pch = 17, cex = 1.0, axes = FALSE, xlab = '', ylab = '', cex.main = 0.8, type = 'n') # rect(0, 115, 4, 153, col = '#fffae6', border = "#fffae6") # rect(0, 185, 4, 215, col = '#fffae6', border = "#fffae6") axis(1, p) grid() lines(Pertinencia_Cluster_2, prof, col = '#009900', pch = 16, cex = 0.8) points(Pertinencia_Cluster_2, prof, col = '#009900', pch = 16, cex = 0.8) legend(0.12, -25, xpd = TRUE, legend = "Pertinência Cluster 2", pch = 16, col = "#009900", cex = 1.0) par(mar= c(5.1, 0, 3, 5)) plot (Pertinencia_Cluster_3, prof, col = "#008B8B", pch = 17, cex = 1.0, axes = FALSE, xlab = '', ylab = '', cex.main = 0.8, type = 'n') # rect(0, 0, 4, 87, col = '#fffae6', border = "#fffae6") axis(1, p) grid() lines(Pertinencia_Cluster_3, prof, col = '#0099ff', pch = 16, cex = 0.8) points(Pertinencia_Cluster_3, prof, col = '#0099ff', pch = 16, cex = 0.8) legend(0.12, -25, xpd = TRUE, legend = "Pertinência Cluster 3", pch = 16, col = "#0099ff", cex = 1.0) title('Clay Minerals (Smectite, Palygorskite, Illite, Chlorite & Kaolinite)', outer = T, line = -2) 

我的情節

在每個plot()命令中添加xlim=c(0,1)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM