Announcement

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

  • Incorporating a dummy date variable into a scatterplot

    Hey there,
    I am trying to produce a graph that gives an indication of how two variables changes over time. One of the variables is recorded monthly (var_mm) and the other is recorded yearly (var_yy). I have a time-variable, date, on the x-axis. It is in the %d format (e.g. 21dec1994). I have a dummy variable, dummy, that is equal to either 1 or 0 for each month of date.

    At the moment, I'm doing my basic graph as:
    Code:
    graph twoway (line var_mm var_yy date),
    I would like to plot a line graph of var_mm and var_yy on date, but have vertical grey bars to indicate periods where dummy is equal to 1. Is this possible?

    Thanks

  • #2
    Well, I'm not that much of a graphics expert, and I don't know off hand how to do what you are asking for. But as an alternative that might have the same kind of visual impact, you might give a look at Nick Cox's -subsetplot- program, which you can get from SSC.

    Comment


    • #3
      Thank you Clyde, I'll have a look.

      Comment


      • #4
        Thanks to Clyde for mentioning subsetplot (SSC) but it sounds what is being sought here is different. Some technique is embedded in this reproducible example

        Code:
         
        set scheme s1color 
        webuse grunfeld, clear 
        su invest if company == 3 
        gen bartop = 50 * ceil(r(max)/50) 
        gen high = D.invest/invest > 0.4
        twoway (bar bartop year if high,  bcolor(gs14)) (line invest year) if company == 3, ytitle(invest) legend(off)
        In Anthony's case, if I understand correctly, the bars should be drawn with something like barw(30) as they correspond to months and the time axis shows a daily date.


        Comment

        Working...
        X