Announcement

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

  • Two-way graph: x axis not properly displaying the dates

    Hi everyone,
    I would appreciate an advice on how to specify the twoway graph command to ensure that x axis is properly displaying the dates. As you can see on the attached graph, the x axis displays the odd values, instead of 2016m10, 2016m11, even though the Month_Baseline_begins variable used in creating the graph is structured as a year/month.

    I used the following code to create the graph:

    twoway (lfitci var15 Month_Baseline_begins if Month_Baseline_begins<=tm(2016m10)) (lfitci var15 Month_Baseline_begins if Month_Baseline_begins>tm(2016m10)

    I would appreciate any advice.
    Attached Files

  • #2
    Please do study FAQ Advice #12 at https://www.statalist.org/forums/help#stata for the following:

    1. Graphs are much easier to understand as .png attachments. The forum software knows nothing about .gph format.

    2. Data examples help mightily.

    Your graph shows months 660(10)700. I would tend to want labels every 12 months, not every 10, and %tm format.

    Some technique within

    Code:
    clear 
    
    set obs 50 
    gen mdate = 645 + _n 
    tsset mdate
    
    gen y = 42 
    
    local start = ym(2014,1)
    loca end = ym(2018, 1)
    line y mdate, xla(`start'(12)`end', format(%tm))
    but also note https://www.stata-journal.com/articl...article=gr0030

    Comment


    • #3
      @Nick Cox: Thanks for being so helpful and responsive to my questions! Greatly appreciate your advice. Dully noted on how to ask for graph advice.

      Comment

      Working...
      X