Announcement

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

  • How to make graph combine pretty

    Click image for larger version

Name:	graph1.png
Views:	1
Size:	81.7 KB
ID:	1666584


    Hi all,

    Any ideas on how to make this so that the bottom picture is centered between the two top ones, and how to make the spacing so I can see it? So far I just have graph combine fig1 fig2 fig3 as my codE#!

  • #2
    To avoid overlapping labels, it often helps to specify the option altshrink.
    https://www.kripfganz.de/stata/

    Comment


    • #3
      there is no data example to play with so here are some basic ideas: on centering the bottom graph: first combine the top two into one row and then combine that new graph with the third; as far as the overlapping text problem, you can try various options including altshrink and iscale(); see
      Code:
      h graph_combine

      Comment


      • #4
        Is there a way to change the size of only one graph? I got the top two combined. But then I combine the third one and it is huge

        Comment


        • #5
          The way to avoid ugly results from graph combine ... is not to use graph combine.

          That will sound flippant, but I have positive suggestions. I would restructure the data and the code so that your three graphs become graphs for different groups of your data.

          Naturally, I don't know your variable names because you don't give a data example.

          Code:
          * sandbox dataset 
          clear 
          set obs 42 
          gen mdate = ym(2017, 12) + _n
          
          set seed 2803 
          foreach v in x1 x2 y1 y2 z1 z2 { 
              gen `v' = rnormal()
          }
          
          * need to reshape 
          rename (x1-z2) (outcome=)
          reshape long outcome, i(mdate) j(which) string 
          
          * fix value and variable labels 
          gen in_or_out = real(substr(which, 2, 1)) 
          label define in_or_out 1 Pittsburgh 2 "rest of known universe"
          label val in_or_out in_or_out 
          gen WHICH = substr(which, 1, 1)
          encode WHICH, gen(group)
          label def group 1 Allegations 2 Risk 3 Homelessness , modify
          label val group group 
          
          
          separate outcome, by(in_or_out) veryshortlabel 
          
          line outcome?  mdate, by(group, note("")) lp(solid dash) xla(702(12)738, format(%tmCCYY) tlength(*0.2) tlc(none)) xtitle("") xtic(695.5(12)743.5, tlength(*3) grid glc(gs12)) legend(col(1))
          Confession: I used the Graph Editor to drag the legend into the obvious corner.

          Advertisement: The time intervals stuff is documented at https://journals.sagepub.com/doi/pdf...867X0800700410

          Advertisement: The strategy here was written up at https://journals.sagepub.com/doi/pdf...36867X20976341

          Click image for larger version

Name:	buck.png
Views:	1
Size:	49.6 KB
ID:	1666595

          Comment

          Working...
          X