Announcement

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

  • Removing text boxes from Kaplan-Meier plots

    I am trying to create Kaplan-Meier plots using this code:

    stset timetoevent if outcome != 3, failure(outcome) scale(1)
    sts test volcatc_p, logrank
    sts graph, by(volcatc_p) sep ci plotopts(lpattern(solid) lwidth(vthin) lcolor(black)) ciopts(lw(vthin) fc(gs12)) ///
    legend(pos(5) ring(0) col(1) size(small) region(c(white)) lab(1 "95% confidence intervals") lab(2 "Survivorship")) ///
    ytitle ("Survivorship", size(small)) ylabel (0.5(.1)1, labsize(vsmall)) yscale(alt) ///
    xtitle("Follow-up period (years)", size(small)) xlabel(0(2)15, labsize(vsmall)) ///
    byopts(title("") sub("") note("") graphregion(color(gs15)) bgcolor(white))


    I have managed to specify everything I need so far except for the two text boxes that appear above each plot (coloured blue and including the text "1." and "2."). I have been through the help files but cannot work out what I need to do to delete, edit, and/or add text to either of these boxes. I realise that I could do this manually in the Graph Editor but would like to understand how it could be done by commands alone.

    Any help would be very welcome!

    Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	130.3 KB
ID:	1405575
    mov

  • #2
    In a graph with by() the titles above each graph are controlled with subtitle(). To suppress these titles, add this option to the command:
    Code:
    subtitle("")
    Example:
    Code:
    sysuse auto
    scatter mpg weight, by(foreign)
    scatter mpg weight, by(foreign) subtitle("")

    Comment


    • #3
      Thanks, although subtitle("") doesn't seem to do the trick in this case.

      I have added byopts(title("Title") sub("Subtitle") note("Note") graphregion(color(gs15)) bgcolor(white)) to my code to show where the "title", "subtitle", and "note" appear. They all appear to be separate entities to the boxes that are wrecking my graph. When I open them manually in the Graph Editor they are described (and have the same properties) as text boxes.

      Click image for larger version

Name:	Graph.jpg
Views:	1
Size:	347.8 KB
ID:	1405612

      Comment


      • #4
        Originally posted by David Metcalfe View Post
        Thanks, although subtitle("") doesn't seem to do the trick in this case.
        It Does. I ran the your commands #1 in a sample data and produced the graph without labels at subtitle:

        Code:
        sts test volcatc_p, logrank
        sts graph, by(volcatc_p) subti("") sep ci plotopts(lpattern(solid) lwidth(vthin) lcolor(black)) ciopts(lw(vthin) fc(gs12)) ///
        legend(pos(5) ring(0) col(1) size(small) region(c(white)) lab(1 "95% confidence intervals") lab(2 "Survivorship")) ///
        ytitle ("Survivorship", size(small)) ylabel (0.5(.1)1, labsize(vsmall)) yscale(alt) ///
        xtitle("Follow-up period (years)", size(small)) xlabel(0(2)15, labsize(vsmall)) ///
        byopts(title("") sub("") note("") graphregion(color(gs15)) bgcolor(white))
        Click image for larger version

Name:	test.png
Views:	1
Size:	184.3 KB
ID:	1405626

        Roman

        Comment


        • #5
          Thank you, both. I had assumed that including sub("") in byopts() was the correct thing to do rather than immediately after by(). I can see from Roman's code that this wasn't correct and should now be sorted. Thanks again.

          David

          Comment

          Working...
          X