SteveS
SteveS

Reputation: 4040

Increase the space between x axis labels ggplot?

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

enter image description here

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

Upvotes: 1

Views: 5934

Answers (1)

Roman Luštrik
Roman Luštrik

Reputation: 70623

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.

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").

Upvotes: 3

Related Questions