3

I'm currently struggling immensely to get the axis text in a graph that I'm designing to automatically format such that it cuts off when it becomes too long. I would ideally implement some sort of character cut off, but I'd ideally prefer to refrain from sticking '\n' after every 2 words. I've dug through the libraries for solutions, but couldn't find any.

It'd also be lovely if I could somehow prevent the graph from shifting upwards, as it makes it incredibly difficult to compare with the 'other' graph next to it.

I've largely been using ggplot and theme settings to make the changes.

Is it possible to make these changes? (1. width limit on axis text, 2. stop area expansion)

Hanna
  • 69
  • 1
  • 10
  • Please provide some code and data to reproduce – HubertL Feb 04 '16 at 22:21
  • This is more of a conceptual problem. All one needs is to rotate labels on the x axis. – Hanna Feb 04 '16 at 22:23
  • 1
    Do you need the code or just the concept? – HubertL Feb 04 '16 at 22:24
  • The concept with the code needed to be insert would be ideal! – Hanna Feb 04 '16 at 22:26
  • 1
    Conceptually, you need to justify the text as well as rotate it. The graph must shift upwards to accommodate the long labels, but you can edit the heights of the graphs (after building them) to make them comparable. If you share some code and data to get where you are so far, I'm sure we can help you with what needs changing. Simulated data or data shared with `dput` is preferred, [see here](http://stackoverflow.com/q/5963269/903061) for tips on making good, reproducible questions. – Gregor Thomas Feb 04 '16 at 22:28
  • Generally, a question with code gets an answer with code. It's much more difficult to effectively write code to answer a code-less, conceptual question. – Gregor Thomas Feb 04 '16 at 22:29
  • I've included the code! – Hanna Feb 04 '16 at 22:34
  • 1
    Also, I've been poking around for some possible duplicate questions. (1) for line breaks [this seems useful](http://stackoverflow.com/q/2351744/903061), (2) for aligning plots, the simplest solution would be to facet with all your data in one data frame. Otherwise we have [this](http://stackoverflow.com/q/35091909/903061), [this](http://stackoverflow.com/q/13294952/903061), [this](http://stackoverflow.com/q/9198637/903061), and [this](http://stackoverflow.com/q/12448428/903061). – Gregor Thomas Feb 04 '16 at 22:40
  • 5
    Lastly, it would probably be best if you edited your image and data to remove potentially offensive language. `"MISSOULA COUNTY HAS A REALLY REALLY LONG LONG LABEL"` would still illustrate the problem nicely. – Gregor Thomas Feb 04 '16 at 22:41

0 Answers0