Announcement

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

  • How to properly combine graphs

    Dear all,
    I'm trying to combine several graphs in a single column, and noticed that the alignment is not optimal due to the space taken by the Y axis labels. Consider the following example:

    Code:
    sysuse auto, clear
    scatter len wei, name(one, replace)
    gen len2 = len*10000
    scatter len2 wei, name(two, replace)
    graph combine one two, col(1)
    As you can see, the graphs are misaligned because the second has longer labels; the xcommon options doesn't correct it. Could you advice on how to proper align?

    Not sure it matters but I have the following options in the "myprofile.do" file:

    grstyle init
    grstyle set graphsize 5cm 5cm
    grstyle set margin "1 1 1 1", pt: graph

  • #2
    I find the allignment of graphs always a problem when using graph combine. So instead I always use the by() option:

    Code:
    sysuse auto, clear
    gen len1 = len
    gen len2 = len1*10000
    keep len? wei
    gen id = _n
    reshape long len, i(id) j(foo)
    scatter len wei, ///
       by(foo, cols(1) yrescale)
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      For more on Maarten Buis's method, see https://journals.sagepub.com/doi/pdf...36867X20976341

      Comment


      • #4
        Thank you Maarten and Nick, I will look into the use of the by() option

        Comment

        Working...
        X