Announcement

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

  • Managing space when combining graph

    Hi,

    I would like to maximize the plot surface when I combine 2 graph. In particular, I would like to increase the size of the y-axis so that the graph is easier to read. I'd like to save space by moving the variable names currently below each graph somewhere they are not cumbersome.

    Code:
    use http://www.stata-press.com/data/r13/uslifeexp, clear
    
    line le le_male  year, saving(male, replace)
    line le le_female year, saving(female, replace)
    
    gr combine male.gph female.gph, col(1) iscale(1)
    Also, I would like to save the combine graph as a .jpeg or any other format I can insert in a Word document. Please help

  • #2
    Hi Francois,

    The below code scales the graph to make it clearer to read (i've also added in some options, which i think make it look nicer - although i accept and embrace the pluralist community in which we all live)

    Code:
    use http://www.stata-press.com/data/r13/uslifeexp, clear
    
    line le le_male  year, ylab(,angle(0)) graphregion(col(white)) legend(region(c(none))) saving(male, replace)
    line le le_female year, ylab(,angle(0)) graphregion(col(white)) legend(region(c(none))) saving(female, replace)
    
    grc1leg male.gph female.gph, col(1) iscale(1) graphregion(col(white)) name(combgraph, replace) //to get this command type -ssc install grc1leg- if you don't already have it
    graph display combgraph, xsize(4) ysize(6) 
    gr export combgraph.jpeg, width(400) height(600) replace
    With regards to putting the legend elsewhere (i.e. not below the plots), I imagine this very much depends on the data you are using (assuming the data you've provided access to is just for illustrative purpose). If there is space in the top left of your graphregion then you could specify pos(11); if there's space in the bottom right then you could specify pos(5). That said, if you specify this option in the grc1leg command, the legend will likely overlap with your plots. An easier route here, if you're really committed to moving the legend on your combined graphs, would be to specify legend(off) on one of your twoway line commands and then use a regular graph combine


    Comment


    • #3
      You might want to look at the brewtheme command in brewscheme. It will allow you to generate scheme files with these generic aesthetics specified so you don't have to hard code all of your aesthetics.

      Comment

      Working...
      X