Announcement

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

  • Issues with legend when exporting graphs as pdf

    Hi,

    When I export the following graph to pdf, the legend section is getting distorted. I am using Stata 16. Does anyone have any solutions?

    Code:
    twoway (histogram speed_notraffic if check==1, by(cityname_corrected, note("")) yla(`labels') color(blue%40) subtitle(, fcolor(white) lstyle(none))) ///        
           (histogram speed_notraffic if check==0, by(cityname_corrected, note("") ixaxes iyaxes imargin(b+5)) yla(`labels') color(yellow%60) subtitle(, fcolor(white) lstyle(none))), ///  
           legend(order(1 "March to June 2020" 2 "March to June 2021" ) region(lstyle(none))) ysize(8) xsize(6) plotregion(lcolor(white))
          
    graph export "${resultsdir}/uncongested/histogram_marchjune2020_marchjune2021_by_city.pdf", replace as(pdf)
    Graph display in Stata:
    Click image for larger version

Name:	Screenshot 2022-10-02 164127.png
Views:	1
Size:	34.5 KB
ID:	1684031



    Graph display in Adobe as pdf:
    Click image for larger version

Name:	Screenshot 2022-10-02 164331.png
Views:	1
Size:	56.5 KB
ID:	1684032


  • #2
    Someone else might have an explanation as to why that is, but I would think one approach to overcome this issue might be to add size(vsmall) symxsize(*.5) to the legend() call

    Comment

    Working...
    X