Announcement

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

  • Recession shading problem

    Hi!
    I want to plot a series (cycger) against time while at the same time include recession shading into the graph. The source of the shading is a series (rec) which is defined as 1=recession, 0=no no recession for each quarter. I came up with the code below, however I encounter 2 problems:

    - the shaded recession bars seems to become thinner from bottom to top (or I might just be too tired to recognise straight lines)
    - the shaded recession bars are on top of the zero line

    Could someone edit this little piece of code, so that the shaded area stays in the background and not on top of the horizontal line at zero?

    Any help is appreciated.


    #delimit ;
    twoway (scatter rec time,
    recast(area)
    bcolor(gs13)
    cmissing(n)
    ylabel(0 1)
    yaxis(1)
    yscale(off))
    (tsline cycger,
    yaxis(2)
    yscale(alt axis(2))
    ytitle("Output Gap", axis(2))),
    yline(0, axis(2))
    ;
    #delimit cr

  • #2
    One more question, I want to change the intervals on the x-axis, say to increments of 5 periods. How would I go about doing that? I've been trying to do it via "tscale" with 1980q1(5)2012q2, but that didn't work for me. I would be really grateful if someone could implement it in the right way for me, as I'm currently at the steeper part if the Stata learning curve.

    Comment


    • #3
      anyone?

      Comment


      • #4
        I know it's quite late, but for anyone searching, a friend and I wrote
        Code:
        ssc install bgshade
        to tackle this exact problem!

        Comment


        • #5
          I'm trying out bgshade, can you have 2 time series on 2 different y axes?

          Comment


          • #6
            Since this thread started there has been an entire paper on that topic at https://www.stata-journal.com/articl...article=gr0067 and a blog post also at https://blog.stata.com/2020/02/13/ad...series-graphs/

            If you're adding recession shading to a graph with two time series on two different axes you just need to plot another variable as backdrop and relate it to one or other y axis.

            Comment

            Working...
            X