2013-07-23 2 views
0

Я отправляю три графика в pdf-файл на той же странице. Знаки оси x, несмотря на то, что имеют одинаковые координаты y в моем коде, находятся на разных высотах. Как это исправить?Диагональный макет ярлыка

Вот пример:

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

ответ

1

Вы можете установить пределы оси с 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() 
Смежные вопросы