r - Diagonal Label layout -
i'm sending 3 graphs pdf file on same page. x axis labels, despite having same y coordinates in code, @ different heights. how fix it?
here example:
pdf("data_output.pdf", height = 8.5, width = 14) graph.frame <- cbind(c(1,2,3,4),c(5,6,7,8),c(9,10,2,2)) par(mfrow = c(1,3), mar = c(7.6, 4.1, 6.1, 2.1)) colnames(graph.frame) <- c("oneoneone", "twotwotwo", "threethreethree") labels <- colnames(graph.frame) temp1 <- barplot(graph.frame[1,], ylab = "aaa", col = terrain.colors(3), xaxt = "n") temp2 <- temp1[1:length(labels)] text(temp2, par("usr")[3] - 0.35, srt = 45, adj = 1, labels = labels, xpd = true) box() temp1 <- barplot(graph.frame[2,], main = "title", ylab = "bbb", col = terrain.colors(3), xaxt = "n") temp2 <- temp1[1:length(labels)] text(temp2, par("usr")[3] - 0.35, srt = 45, adj = 1, labels = labels, xpd = true) box() temp1 <- barplot(graph.frame[3,], ylab = "ccc", col = terrain.colors(3), xaxt = "n") temp2 <- temp1[1:length(labels)] text(temp2, par("usr")[3] - 0.35, srt = 45, adj = 1, labels = labels, xpd = true) box() dev.off()
you can set axis limits ylim:
?par barplot(graph.frame[1,], ylab = "aaa", col = terrain.colors(3), ylim="c(0,10), xaxt = "n") pdf("data_output.pdf", height = 8.5, width = 14) graph.frame <- cbind(c(1,2,3,4),c(5,6,7,8),c(9,10,2,2)) par(mfrow = c(1,3), mar = c(7.6, 4.1, 6.1, 2.1)) colnames(graph.frame) <- c("oneoneone", "twotwotwo", "threethreethree") labels <- colnames(graph.frame) temp1 <- barplot(graph.frame[1,], ylim=c(0,10),ylab = "aaa", col = terrain.colors(3), xaxt = "n") temp2 <- temp1[1:length(labels)] text(temp2, par("usr")[3] - 0.35, srt = 45, adj = 1, labels = labels, xpd = true) box() temp1 <- barplot(graph.frame[2,], ylim=c(0,10),main = "title", ylab = "bbb", col = terrain.colors(3), xaxt = "n") temp2 <- temp1[1:length(labels)] text(temp2, par("usr")[3] - 0.35, srt = 45, adj = 1, labels = labels, xpd = true) box() temp1 <- barplot(graph.frame[3,],ylim=c(0,10),ylab = "ccc", col = terrain.colors(3), xaxt = "n") temp2 <- temp1[1:length(labels)] text(temp2, par("usr")[3] - 0.35, srt = 45, adj = 1, labels = labels, xpd = true) box() dev.off()
Comments
Post a Comment