Quantcast
Channel: Left-adjust (hjust = 0) vertical x axis labels on facets with free scale - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Left-adjust (hjust = 0) vertical x axis labels on facets with free scale

$
0
0

I have decided to rephrase this question. (Editing would have taken more time and in my opinion would also not have helped the OP.)

How can one left-adjust (hjust = 0, i.e., in text direction) over facets, when scale = 'free_x'?

I don't really think that left-adjustment of x-labels is a very necessary thing to do (long labels generally being difficult to read, and right-adjusting probably the better choice) - but I find the problem interesting enough.

I tried with empty padding to the maximum character length, but this doesn't result in the same length for all strings. Also, setting axis.text.x = element.text(margin = margin()) doesn't help. Needless to say, hjust = 0 does not help, because it is adjusting within each facet.

library(ggplot2)diamonds$cut_label <- paste("Super Dee-Duper", as.character(diamonds$cut))ggplot(data = diamonds, aes(cut_label, carat)) +  facet_grid(~ cut, scales = "free_x") +  theme(axis.text.x = element_text(angle = 90))

enter image description here

The red arrows and dashed line indicate how the labels should adjust. hjust = 0 or margins or empty padding do not result in adjustment of those labels over all facets.

Data modification from this famous question


Viewing all articles
Browse latest Browse all 5

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>