Announcement

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

  • Ordering legend only in graph

    I am trying to order the legend with the better outcome group up top in the legend and the worse outcome at the bottom. I am unable to finagle to get the right options. Tried fiddling with plot and legend(order) but I can't seem to get it right. Needed "Missense" up top in the legend and then the "Other" below it.

    local v mis2
    foreach var of local v{
    qui sts graph ///
    , by(`v') ///
    plot1(lc(navy) lp(solid)) ///
    plot2(lc(dkorange) lp(-)) ///
    plotregion(margin(medium) icolor(white) color(white) ) ///
    graphregion(margin(vsmall) icolor(white) color(white) ) ///
    title("24-month (OS) analysis", size(medium)) ///
    xtitle("Time since tMN/AML diagnosis (months)", size(small)) ///
    xlabel(0(5)25, labs(small)) ylabel(0(0.25)1, angle(0) labs(small)) ///
    ytitle("Proportion surviving", size(small) margin(medium)) ///
    legend(order(1 "Other TP53 mutations (n = )" 2 "Missense P53 mutations (n= )") ///
    col(1) size(small) symxsize(*0.5) margin(small) rowg(*0.1) ring(0) pos(2)) ///
    risktable(,order(1 "Other" 2 "Missense") size(vsmall) title(,size(small))) ///
    text(0.28 8 "p<0.04", place(sw) size(small)) ///
    name(km_OS24, replace)
    Click image for larger version

Name:	km_OS24.png
Views:	1
Size:	34.5 KB
ID:	1682866



  • #2
    You literally have to specify the order that you want within -order()-. Extra tip, no charge, italicize the sample sizes if you include them within the legend.

    Code:
    legend(order(2 "Missense P53 mutations ({it:n}= )" 1 "Other TP53 mutations ({it:n}= )" ))

    Comment


    • #3
      Hi Girish
      Just swap the order you list them within order( ). Take your line
      Code:
      legend(order(1 "Other TP53 mutations (n = )" 2 "Missense P53 mutations (n= )")
      and switch positions of 1 and 2, so it becomes:
      Code:
      legend(order(2 "Missense P53 mutations (n = 57)" 1 "Other TP53 mutations (n = 24)")

      Comment


      • #4
        Thanks both Tim Morris and Andrew Musau Learnt something.

        Comment

        Working...
        X