Announcement

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

  • Generate quarterly date for graph as YYQQ and legend position

    Dear Statlisters,

    Hope you can help me in this exercise about the data and legends (graph)

    First, I have quarterly data (2000-2019) stored in time variable as 2000q1, 2000q2... until 2019q4, I want it to appear as 00-Q1 or 00Q1 until 19-Q4 (Year-Quarter) where the year is two digits. I want to do this in order to graph it. I attach a screen shot of a photo that I wish to adopt its time (x) label.

    Second, I want the legends to appear in the right corner in 6 rows with a small margin as shown in the attached image.

    Thank you
    Click image for larger version

Name:	stata_graph.png
Views:	1
Size:	41.5 KB
ID:	1566780


  • #2
    You can use this as a starting point.

    Code:
    clear
    set obs 50 
    
    gen quarter = tq(1999-4) + _n 
    format quarter %tqYY-!Qq
    
    gen x = runiform() + _n
    gen y = runiform() - .4 + _n 
    twoway line x y quarter, legend(col(1) position(3) ring(0) region(lcolor(white))) xtitle("")
    See
    Code:
     
    help legend options

    Comment


    • #3
      Many thanks Justin. That helps.
      Regards

      Comment

      Working...
      X