Announcement

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

  • Keep displaying two graphs

    Dear Stata experts,

    I have one question: I want to display at the same time two windows of graphs generated with the command graph combine.

    For the first combination I do this

    Code:
    hist ideologia, norm name(G1) nodraw
    kdensity ideologia, norm name(G2) nodraw
    graph combine G1 G2
    Later in the dofile i do this

    Code:
    twoway (histogram ideologia if joven==1, start(0) width(1) color(red)) ///
    (histogram ideologia if joven==0, start(0) width(1) ///
    fcolor(none) lcolor(black)), legend(order(1 "Menores de 30" 2 "Mayores de 30" )) name(G7) nodraw
    
    twoway (kdensity ideologia if joven==1, width(1) color(red)) ///
    (kdensity ideologia if joven==0, width(1) ///
    fcolor(none) lcolor(black)), legend(order(1 "Menores de 30" 2 "Mayores de 30" )) name(G8) nodraw
    
    graph combine G7 G8
    But when I execute the dofile the first combination of graphics appears but inmediately is substituted with the second one. I want to keep the two graphs combinations (displayed in different windows) when i run the dofile. Is that possible? How?

    Thank you in advance.

  • #2
    I don't know how to have both shown in the stata graph window, but you can always export the combined graphs and open them using the standard windows/... tools

    Comment


    • #3
      You can add the name() option, this will prevent the graph "overwriting" each other. For example:

      Code:
      sysuse auto
      scatter price mpg, name(price)
      scatter weight mpg, name(weight)
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        You can also add the -set autotabgraphs on- and reduce the number of windows by using tabs in one window.

        Code:
        set autotabgraphs on
        
        sysuse auto
        scatter mpg weight, by(for) name(a, replace)
        scatter price mpg, by(for) name(b, replace)

        Comment

        Working...
        X