Announcement

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

  • Problem shading area between two vertical lines

    I'm using Stata/IC 14.2.

    I want to shade the area between two vertical lines, but have two problems:
    1. The shading does not cover the entire vertical range of the plot. I believe I could fix this if there were a way to identify the maximum and minimum y values that Stata includes in graph region, but I have been unable to figure out how to do this. Is there a way to know before plotting what these values are? I am making several figures in a loop so eyeballing it won't help.
    2. The vertical lines are covered by the shading. Is there a way to fix this?
    Below is an example which illustrates what I am trying to do:

    Code:
    clear
    sysuse sp500
    
    gen t = _n
    
    twoway (scatteri -50 70  -50 80, bcolor(gs12) recast(area) plotr(m(zero))) ///
           (scatteri 90 70  90 80, bcolor(gs12) recast(area) plotr(m(zero))) ///
           (scatter change t), ///
           xline(70 80, lcolor(black) lpattern(dash)) ///
           legend(off)
    This produces the following figure:
    Click image for larger version

Name:	Graph.png
Views:	2
Size:	30.8 KB
ID:	1438426

    If I could replace the values of -50 and 90 with the edges of the plot area I believe that would solve #1. I'm not quite sure about #2.


Working...
X