0

同じページの pdf ファイルに 3 つのグラフを送信しています。コードで同じ y 座標を使用しているにもかかわらず、x 軸ラベルの高さが異なります。どうすれば修正できますか?

次に例を示します。

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

1 に答える 1

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()
于 2013-07-23T19:53:15.747 に答える