Dear All,
I am puzzled and confused as to how Stata decides on the width of the legend columns when their number is fixed, as in the following example.

Produced by the following code:
I can't understand:
Is there any way to auto-arrange the legend so that it looks nice? Meaning no overlaps of text, no spill-overs outside and other reasonable expectations. Simply making the font size responsive to the text size would give it a much better appearance. Alternatively, automatic trancation with an ellipsis at the end of the string would also be useful.
Clearly, changing the order of keys makes the picture nice again:

It is possible to find such small adjustments almost in all cases, but that requires a human to look at the chart and invent a solution. I am looking for something more robust and automatic.
PS: this is very reminiscent of this topic here: https://www.statalist.org/forums/for...or-legend-keys but not calling for wrapping the texts.
Thank you, Sergiy
I am puzzled and confused as to how Stata decides on the width of the legend columns when their number is fixed, as in the following example.
Produced by the following code:
Code:
clear sysuse auto label variable length "Length in inches from bumper to bumper" label variable price "Market reference price at beginning of ref. period" twoway scatter weight length price mpg price, legend(cols(2))
- what makes the columns to be of unequal widths? (in my real world example the difference is more dramatic) and
- why the text of keys overflows out of the legend or into the next column?
Is there any way to auto-arrange the legend so that it looks nice? Meaning no overlaps of text, no spill-overs outside and other reasonable expectations. Simply making the font size responsive to the text size would give it a much better appearance. Alternatively, automatic trancation with an ellipsis at the end of the string would also be useful.
Clearly, changing the order of keys makes the picture nice again:
Code:
twoway scatter weight length price mpg price, legend(cols(2) order(1 2 4 3))
It is possible to find such small adjustments almost in all cases, but that requires a human to look at the chart and invent a solution. I am looking for something more robust and automatic.
PS: this is very reminiscent of this topic here: https://www.statalist.org/forums/for...or-legend-keys but not calling for wrapping the texts.
Thank you, Sergiy
Comment