Announcement

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

  • Data visualization - How to break a label on tline into multiple lines?

    Hello,

    Please see my current graph.


    I would like to split the "Arab Spring" label in two lines

    My current code is as follows (I colored the line of the code in question in red to make it easier to find):

    graph twoway (scatter vae year if countryname1==196, connect(direct) color(yellow)) (scatter vae year if countryname1==110, connect(direct) color(green) title("Voice and Accountability") ytitle("Index" "Score", orient(horizontal)) ylabel(,angle(0)) xtitle("") xlabel(2008(2)2020,grid) ylabel(,grid) text(0.4 2019.5 "Tunisia") text(-1.35 2019.5 "Libya") text(-1.55 2019.5 "Egypt")) (scatter vae year if countryname1==58, connect(direct) color(purple) tline(2010, lc(gray)) tlabel(2010 "Arab Spring", add labsize(*.75)) legend(label(1 "Tunisia") label(2 "Libya") label(3 "Egypt") col(3)))

    I have tried several hours to find the right way to do this and I can't. I would tremendously appreciate any suggestions.

    Thank you very much for your help and suggestions,
    Attached Files

  • #2
    Code:
    tlabel(2010   `""Line 1" "Line 2""')
    See also: Nick Cox's: Stata tip 24: Axis labels on two or more levels www.stata-journal.com/article.html?article=gr0020

    Comment


    • #3
      Thank you, SO, so much Scott - I really appreciate it. I had stumbled upon this tip before and tried it, but didn't work. This time, it worked like a charm!

      PS - the link you posted is invalid. If it is possible, would you kindly post it again?

      Comment


      • #4
        https://www.stata-journal.com/articl...article=gr0020

        or:

        https://journals.sagepub.com/doi/pdf...867X0500500316



        Comment

        Working...
        X