Announcement

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

  • problem about combining graphs

    I created several graphs (total of 6) using survival methods:
    here is my sample code:

    stset "time to event", id(usubjid) failure(event==1) scale(30) exit (time 1800)
    sts graph, failure by(subgrouptreat) ytitle("Cumulative Incidence (%)", size(small)) ylabel(0 "0" 0.05 "5" 0.10 "10" 0.15 "15" 0.20 "20") xtitle("months") title ("title of the graph") legend(on order(1 "subgroup1 pla" 2 "subgroup1 tx" 3 "subgroup2 plac" 4 "subgroup2 tx" 5 "subgroup3 plac" 6 "subgroup3 tx"))legend(position(1) size(tiny) rows(1))

    graph save graph1.gph, replace

    I do this for 6 graphs

    then combine them using:

    graph combine graph1.gph graph2.gph graph3.gph graph4.gph graph5.gph graph6.gph,
    graph export combined_graphtreat.png, as(png) width(3000) height(2000) replace

    however, I encounter a problem after combining all the graphs, the Ytitle - cumulative incidence is superimposed into the Yaxis labels (see attached .png)

    is there any work around for this, I have tried margins and iscale which did not work

    thank you!


    Click image for larger version

Name:	sample graph.png
Views:	1
Size:	19.9 KB
ID:	1780539

  • #2
    You could consider adding the x and y titles to the combined graph rather than having these repeated.

    Code:
    webuse drug2b, clear
    sts graph, by(drug)  ytitle("Cumulative Incidence (%)") saving(gr1, replace)
    gr combine  gr1.gph gr1.gph gr1.gph gr1.gph gr1.gph gr1.gph 
    
    
    sts graph, by(drug) saving(gr1, replace) xtitle("")
    gr combine  gr1.gph gr1.gph gr1.gph gr1.gph gr1.gph gr1.gph , l1title("Cumulative Incidence (%)") b1title("Analysis time")
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	77.3 KB
ID:	1780551



    Click image for larger version

Name:	Graph1.png
Views:	1
Size:	74.0 KB
ID:	1780552

    Comment


    • #3
      You should do the same with the legends in case these are common. See, e.g.,

      Code:
      view net describe grc1leg2, from("http://digital.cgdev.org/doc/stata/MO/Misc")

      Comment


      • #4
        got it this works! thank you very much for your help!

        Comment

        Working...
        X