Announcement

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

  • Help needed with labeling y axis on a twoway graph

    Dear Statalist users,

    I am creating a graph where I display recurrent event times over a period of 17 years. I am looking at two different events (CT and NT) within the same graph.

    As I have my coding now, I am only able to label subjects by number, but I would like to be more specific and use words. In total I have 12 subjects (6 for CT, and 6 for NT). Instead of labeling them 1 to 12, I would like to label them as 1.NT, 2.NT, 3.NT, 4.NT, 5.NT, 6.NT 1.CT, 2.CT, 3.CT, 4.CT, 5.CT, 6.CT. while keeping their current order.

    My coding is currently as follows:

    twoway(line id time, connect(L)) (scatter id time if event==1, msymbol(t) mcolor(maroon)) (scatter id time if event==2, msymbol(s) mcolor(maroon)) (scatter id time if t_end==18, mcolor(maroon) msymbol(Oh)), ylabel(1 2 3 4 5 6 7 8 9 10 11 12) legend(label(1 time under risk) label(2 uptake event NT) label(3 uptake event CT) label(4 right censoring)) xtitle("time (in years)") ytitle("subjects") title("Schematic plot for recurrent time-to-event data") xlabel(0(1)18)
    My graph currently looks as follows:

    Graph.stata.gph


    I am unsure how to modify my coding to achieve this. Any help would me much appreciated.

    Jesus P.


  • #2
    replace
    Code:
    ylabel(1 2 3 4 5 6 7 8 9 10 11 12)
    with
    Code:
    ylabel(1 "1.NT" 2 "2.NT" 3 "3.NT" 4 "4.NT" 5 "5.NT" 6 "6.NT" 7 "1.CT" 8 "2.CT" 9 "3.CT" 10 "4.CT" 11 "5.CT" 12 "6.CT")

    Comment


    • #3
      Thank you. This worked perfectly.

      Jesus P.

      Comment

      Working...
      X