【发布时间】:2018-09-05 14:20:23
【问题描述】:
我正在尝试将三个数字合并在一起。 (见下图)
这三个的 x 值都在 0.0 和 1.0 之间变化。 但只有值更接近最终 x 值 (1.0) 的图才具有整个 x 轴范围。
查看函数 axis(),我看到“省略了非有限(无限、NaN 或 NA)值”,因此没有 1.0 左右值的图不会有等效值是有道理的x 轴。
首先我认为这可能是因为它们的大小,但即使从图中减少 x 轴的 cex 也是如此。
我该如何解决这种情况?我真的希望所有三个图表都有整个 x 轴,在 0.0 - 1.0 之间变化。
我使用的脚本是基本的 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)
【问题讨论】:
-
嗨!为了更容易为您提供帮助,请提供一些示例数据和您的代码,以及您是如何制作绘图的。
-
太好了,你得到了代码!现在缺少一些样本数据,您的轴调用中的 p 和 t 是什么?尝试使您的示例最小且可重复(如here 等解释)
标签: r