增加x轴标签ggplot之间的空间?

时间:2023-02-09 16:37:08

Here is my ggplot and I need to adjust the spacing between x axis labels and make the plot larger. Please advise what is missing here? Trying to play with expand but without any luck:

这是我的ggplot,我需要调整x轴标签之间的间距,使图更大。请告知这里缺少什么?试着玩扩展,但没有任何运气:

ggplot(device_contacts_jaccard_android_ios, aes(x = factor(uuid_lev), y = j, fill = factor(android))) +
  geom_boxplot() +
  facet_wrap( ~ dt) +
  scale_x_discrete(expand=c(0, 0.5)) +
  theme(axis.text.x = element_text(angle = -90, hjust = 0))

增加x轴标签ggplot之间的空间?

I have checked other answers here, no one solved my issue, correct me if I am wrong.

我在这里检查了其他答案,没有人解决我的问题,如果我错了,请纠正我。

1 个解决方案

#1


2  

Use ggsave or pdf(...);...; dev.off() to increase the output size of the image. Once you do that, the space between axis text labels should increase. You could also decrease the font using element_text(size = 7), for example.

使用ggsave或pdf(...); ...; dev.off()增加图像的输出大小。一旦这样做,轴文本标签之间的空间应该增加。例如,您还可以使用element_text(size = 7)减少字体。

Note that in ggsave(..., size, width) are in inches, by default. Good starting points are width = 8 and height = 8. If you want to change the units, try ggsave(..., units = "cm").

请注意,默认情况下,ggsave(...,大小,宽度)以英寸为单位。好的起点是width = 8和height = 8.如果你想改变单位,试试ggsave(...,units =“cm”)。

#1


2  

Use ggsave or pdf(...);...; dev.off() to increase the output size of the image. Once you do that, the space between axis text labels should increase. You could also decrease the font using element_text(size = 7), for example.

使用ggsave或pdf(...); ...; dev.off()增加图像的输出大小。一旦这样做,轴文本标签之间的空间应该增加。例如,您还可以使用element_text(size = 7)减少字体。

Note that in ggsave(..., size, width) are in inches, by default. Good starting points are width = 8 and height = 8. If you want to change the units, try ggsave(..., units = "cm").

请注意,默认情况下,ggsave(...,大小,宽度)以英寸为单位。好的起点是width = 8和height = 8.如果你想改变单位,试试ggsave(...,units =“cm”)。