【发布时间】:2019-09-24 00:54:00
【问题描述】:
我想使用基数 R 生成两个图形,都显示条形图。第一个图应该包含两个条形图,第二个图应该包含四个条形图。
我使用 par(mfrow = c(...)) 在一个图中排列多个条形图。 我自己制作数字没有问题,但是当我保存数字时,条形宽度和刻度标签的大小不同。
据我了解,当我生成带有四个条形图的第二个图形并在导出时选择第一个图形的两倍宽度时,条形图和标签应在文件中以相同大小显示。但是,标签要小得多,并且第二个图中的条具有不同的宽度。谁能告诉我为什么?
这里是一个简单的例子:
png(filename="plot1.png", width=200, height=300, bg="white")
par(mfrow = c(1, 2), mar = c(1, 2, 1, 1), oma = c(0, 0, 0, 0))
barplot(height = c(2,3), width = 1, xlim = c(0,2))
barplot(height = c(2,3), width = 1, xlim = c(0,2))
dev.off()
png(filename="plot2.png", width=400, height=300, bg="white")
par(mfrow = c(1, 4), mar = c(1, 2, 1, 1), oma = c(0, 0, 0, 0))
barplot(height = c(2,3), width = 1, xlim = c(0,2))
barplot(height = c(2,3), width = 1, xlim = c(0,2))
barplot(height = c(2,3), width = 1, xlim = c(0,2))
barplot(height = c(2,3), width = 1, xlim = c(0,2))
dev.off()
情节 1:
情节 2:
【问题讨论】:
-
很遗憾没有。即使我按照此答案中的建议使用代码导出图,我的条形宽度和刻度标签不等问题仍然存在。我编辑了我的问题以使其更清楚。
标签: r plot graph bar-chart par