Announcement

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

  • Graphing with date labels

    I am trying to create a graph using the twoway command with monthly dates on my x-axis, in the format (%tm). I would like these dates to be displayed as "Jan 2010, Feb 2010, Mar 2010" etc. instead of "2010m1, 2010m2, 2010m3", how may I do this?

  • #2
    Hi Ann,

    Perhaps, the following code may help:
    Code:
    xlabel(2010m1 "Jab 2010"  2010m2 "Feb 2010" 2010m3 "Mar 2010")

    Comment


    • #3
      You can fine tune how a date is displayed by adding stuff after %tm. The details are explained in help datetime_display_formats. However, if you don't want the details (for now) than the short answer to your question is that you format your time variable as: %tmMon_ccYY
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Even with @Maarten Buis's accurate advice I fear that your axis labels will now take up a great deal of space. Even with just 12 observations in 2010 the result of this is to me unbearable -- unless you resort to the ugly xla(, ang(v)):

        Code:
        clear
        set obs 12
        gen foo = 42
        gen mdate = ym(2009, 12) + _n 
        format mdate %tmMon_CCYY
        line foo mdate, xla(600/611)
        What is the range of your monthly dates?


        Dung Le #2 won't work.


        Code:
        . line foo mdate, xla(2010m7 "July 2010")
        invalid label specifier, :  2010m7 "July 2010":
        r(198);

        Comment

        Working...
        X