Announcement

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

  • Format month and year x-axis label for twoway

    Hi Statalist,

    I have a question which I believe is simple for seasoned Stata programmers (not me!). I am trying to produce a graph using -twoway- and I have a variable for time (time) for my x-axis currently formatted as %tmMonYY. How might I format the date such that the Month is in the line on top of the year on the graph?

    So instead of:

    Jun06

    I have:

    Jun
    06

    Thanks!

    I am using Stata SE x64 ver 13.1 with Win 7 x64 and with 8 GB of ram.

  • #2
    Here's one work-around:

    Code:
     
    use http://www.stata-press.com/data/r10/air2.dta, clear
    gen mdate = t + ym(1948, 12)
    format mdate %tmMonYY
    line air mdate if mdate < ym(1955, 12), xla(, format(%tmMon)) xmla(-132(12)-60, format(%tmYY) labsize(medsmall) tlength(*7) tlcolor(none))
    You use axis labels for one part and minor axis labels for the other. You have to work out where you want them and to adjust away from the minor axis labels defaults.

    Comment


    • #3
      @
      Last edited by Hamid muili; 08 May 2023, 11:45.

      Comment


      • #4
        Nick Cox , I'm also having an issue, I ploted a times series graph from 1980m1 to 2020m1, the gap between each period is 10 yrs. Pls how do I reduce the period to 5yrs each for clarity.. I used twoway command.

        Comment


        • #5
          Data example please

          Comment

          Working...
          X