Announcement

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

  • Aligning the text with the 'boxes' in a histogram legend

    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:	1744058


    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: I tried posting this question earlier (see here) but couldn't see it listed in the forum. I'm reposting from a different browser.

  • #2
    A small update: I ran this code on somebody else's laptop (with STATA 18) and the problem disappeared! So the problem is either caused by:
    1) An issue with STATA 16 (my version)
    2) An issue induced by the Latin Modern font (I think this is most likely).
    Despite this, I believe that the problem should be fixable even if I stick with the Latin Modern font.

    Comment

    Working...
    X