Announcement

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

  • Graph: Shade quadrant of scatterplot

    I'm drawing a scatterplot where the y-axis features the current values of a series and the x-axis contains lagged values of that series. Points that appear in quadrant I of this scatterplot are of particular interest, and I would like to highlight that by shading that area (above y=0, to the right of x=0) to help viewers interpret the graph. I have tried using an area plot and creating a variable that holds the maximum value of y, but that results in the appearance of a line rather than the area I want. Any thoughts on how to do this?

    This is what I've tried.
    Code:
     twoway (area g_`y'1 x  if year==2016) ///
            (scatter g_`y'1 l.g_`y'1 if year==2016, mlabel(short) mlabs(tiny) mlabangle(45)), ///
            xtitle("1-Year `y' Change, 2014-2015") ytitle("1-Year `y' Change, 2015-2016") ///
            yline(0) xline(0)

  • #2
    Code:
     
    clear
    set seed 2803
    set obs 100
    set scheme s1color 
    gen y = rnormal()
    gen x = rnormal()
    twoway scatteri 0 0 3 0 3 3 0 3 0 0 , recast(area) color(blue*0.3) ///
    || scatter y x, ms(Oh) yla(-3/3) xla(-3/3) legend(off)
    Click image for larger version

Name:	shaded.png
Views:	1
Size:	10.4 KB
ID:	1301489

    Comment


    • #3
      Thanks, Nick.

      Comment

      Working...
      X