Announcement

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

  • labeling each x axis when using xtline

    Consider the code below:

    use http://www.stata-press.com/data/r15/xtline1
    xtset person day
    xtline calories, tlabel(#3)

    I have a problem like this and would like to have the x axis explicitly marked for all three graphs (it is missing from Tess)

    Is there a way to do this?
    I see the by option ixaxes but cannot figure out how to use it here.
    Thanks

  • #2
    Code:
    xtline calories, tlabel(#3) byopts(ixaxes)

    Comment


    • #3
      Thanks very much that worked. I think the problem was that I did not realize I could have two byopts w/in the same graph.

      Comment


      • #4
        The example graph consists of a graph panel for each individual (panel!). For just 3 individuals, I suggest that fabplot from SSC is competitive.


        Here is the complete syntax.

        Code:
        set scheme s1color 
        
        use http://www.stata-press.com/data/r15/xtline1, clear
        xtset person day
        xtline calories, tlabel(#3)
        
        local x 
        
        foreach m in 1 4 7 10 13 { 
            local this = dofm(ym(2001, 12) + `m') 
            local x `x' `this'
        }
        
        * ssc install fabplot 
        fabplot line calories day, by(person) xla(`x', format(%tddd_Mon)) xtitle("")
        Click image for larger version

Name:	fabplot4.png
Views:	1
Size:	72.6 KB
ID:	1575163


        I fooled around with the x axis labels and title, although that is not my main point.

        The fabplot idea (think "front-and-back plot") is that the other series are backdrop for each series in turn. Conversely, the xtline default used is one series (that coloured blue above) in each panel, making it necessary -- for effective comparison -- to pick up each series mentally and superimpose it on the other two.

        More at https://www.statalist.org/forums/for...ailable-on-ssc except that subsetplot is in essence superseded by fabplot, so that at most early posts in the thread show examples of the main strategy.

        The thread at https://stats.stackexchange.com/ques.../190328#190328 is more up-to-date in terms of references using this approach that I know about;

        Comment

        Working...
        X