0

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. But only the plot whose values come real closer to the final x-value (1.0) have the entire x-axis range.

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.

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.

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.

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

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)

My plot

Gabriel Lucas
  • 170
  • 1
  • 2
  • 14
  • Hi! To make it much easier to help you, please provide some sample data and your code, how you produced the plot. – kath Sep 05 '18 at 14:22
  • Great, you got the code! Now some sample data is missing and what is p and t in your axis calls? Try to make your example minimal and reproducible (as explained e.g. [here](https://stackoverflow.com/a/5963610/5892059) ) – kath Sep 05 '18 at 15:52

1 Answers1

1

Add xlim=c(0,1) in each of your plot() commands.

DanY
  • 5,920
  • 1
  • 13
  • 33