简体   繁体   English

如何在X轴图中不忽略NA值? [R]

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

I'm trying to do a plot merging three figures together. 我正在尝试绘制将三个图形合并在一起的图。 (See my figure below) (请参见下面的图)

All of the three have x-values varying between 0.0 and 1.0. 所有这三个值的x值都在0.0到1.0之间变化。 But only the plot whose values come real closer to the final x-value (1.0) have the entire x-axis range. 但是,只有其值真正接近最终x值(1.0)的图才具有整个x轴范围。

Looking at the function axis(), I see that "non-finite (infinite, NaN or NA) values are omitted", so makes sense that the plot who don't have values around 1.0 wouldn't have a equivalent x-axis. 查看函数axis(),我看到“省略了非限定(无限,NaN或NA)值”,因此有意义的是,没有1.0左右值的绘图将没有等效的x轴。

First I thought that it could be because of their sizes, but even diminishing the cex from the plot the x-axis continues the same. 首先,我认为可能是因为它们的大小,但是即使从绘图中减小CEX,X轴也将保持不变。

How can I work around this situation? 我该如何解决这种情况? I really want that all the three graphs have the entire x-axis, varying between 0.0 - 1.0. 我真的希望所有三个图形都具有整个x轴,且在0.0-1.0之间变化。

The script that I'm using is the basic axis() function, like: axis(1, c(0.0, 0.2, 0.4, 0.6, 0.8, 1.0)) 我使用的脚本是基本的axis()函数,例如:axis(1,c(0.0,0.2,0.4,0.6,0.8,1.0))

Entire Code (It's a bit messy, sorry): 整个代码(有点混乱,抱歉):

 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