Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Vertically aligning the text and box in

    I am trying to make a two-way histogram. Unfortunately, the text and the 'box' in the legend are not exactly aligned. To see the issue, consider the example:
    Code:
    sysuse auto.dta
    twoway (histogram mpg, discrete bfcolor(white) bcolor(black*.60)) ///        
           (histogram rep78, discrete color(green%20)), ///  
           legend(order(2 "MPG Variable" 1 "REP78 Variable")) xsc(titlegap(*5)) plotregion(margin(zero))
    This produces the following histogram:

    Click image for larger version

Name:	image_33881.png
Views:	2
Size:	123.6 KB
ID:	1744033

    As can be seen, "MPG Variable" is not aligned with the green box: it is a bit too low. An analogous comment applies to "REP78 Variable". Is there an easy way to fix this? Note: my default font is Latin Modern, although I don't think that this causes the issue.

    Many thanks in advance.

    Edit: the title should be: "Vertically aligning the text and box in vertical histograms", sadly I don't seem to be able to edit this...
    Last edited by Itzhak Rasooly; 21 Feb 2024, 07:46.
Working...
X