Announcement

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

  • Shaded graph

    Dear all,

    I was wondering if anyone could point me in the right direction on how to produce a shaded graph in Stata.

    Let's say I have data on the prices of 3 products over an 8-year period (annual price observations) and I'd like to plot the price trends.

    Code:
    graph twoway (line prod1 prod2 prod3 year, clcolor(blue red green)), ///
    xlabel(2009(2)2016) xtitle("") legend( symys(*.5) symxs(*.5) size(3) region(c(none)) ///
    bm(tiny) rows(1) order(1 "Product 1" 2 "Product 2" 3 "Product 3") )
    graph display, scheme(sj)
    I'd like to produce a shaded figure where the the background is shown in white for 0-100, in light gray for 101-150, and slightly darker gray for 151+.

    Is this possible to accomplish?

    Thank you very much.

  • #2
    I think you may need to use something like twoway rarea to lay down different shadings first, then plot your data on top. Generic advice within https://www.stata-journal.com/articl...article=gr0067

    gr0067 is thereby revealed as an otherwise unpredictable search term for related posts in this forum. (Perhaps the leading empirical example is shading recession periods on time series plots.)
    Last edited by Nick Cox; 26 Nov 2018, 04:19.

    Comment


    • #3
      You might also have a look at this Stata tip:

      https://www.stata-journal.com/sjpdf....iclenum=gr0050

      The authors show how to construct "confidence shades". I guess you can adapt the code there for your purpose.

      Comment

      Working...
      X