I am using graph twoway scatter
and adding my own ylabels
.
I often have long labels and break them over multiple lines. However, I encounter a problem when I want to break some labels over two lines, but not others.
When I do this, the single-line labels are off-center relative to their tick
marks, as if Stata expected them to also have two lines.
See below for a simple illustration:
sysuse auto, clear
/* This graph has one long label and one short but both are off-center
relative to their tick marks */
twoway scatter length weight, ytitle("") ylabel(220 ///
`" "This one is a very long" "label, broken up" "' 140 "This one is not", ///
ang(horizontal))
/* The order of labels on the graph *does not* appear to matter */
twoway scatter length weight, ytitle("") ylabel(180 ///
`" "This one is a very long" "label, broken up" "' 220 "This one is not", ///
ang(horizontal))
/* But the order in the command *does* appear to matter */
twoway scatter length weight, ytitle("") ylabel(220 ///
"This one is not" 140 `" "This one is a very long" "label, broken up" "', ///
ang(horizontal))
This is not a huge problem, but one I have noticed for years and knowing why my graphs behave this way would be nice.
It is not clear what exactly causes this but one can make an educated guess.
It appears that if you change your code to include all
strings
indouble quotes
, the problem goes away. Using your toy example:This probably has to do with how the code is parsed internally and suggests that Stata expects the second
string
to have the same number of quotes as the first one.Only StataCorp can definitively answer your question, but hopefully the above example provides you with a clue about what is going on.