Announcement

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

  • Shading region between two lines in a twoway graph


    Dear All,

    Below is my code for the graph that I have attached:


    twoway (line arrears_high month_stata, lcolor(midblue) lwidth(medthin) lpattern(solid)) (line arrears_low month_stata, lcolor(dknavy) lwidth(medthin) lpattern(solid)), ytitle(Average Arrears (INR)) ytitle(, size(small) margin(zero)) ylabel(#5, labsize(vsmall) nogrid) xtitle(Month) xtitle(, size(small) margin(zero)) xscale(line) xlabel(#13, labsize(vsmall)) legend(order(1 "High Response" 2 "Low Response")) tline(2022m1, lpattern(solid) lcolor(red)) tline(2021m7, lpattern(solid) lcolor(red)) tline(2021m12, lpattern(dash) lcolor(gray)) tline(2022m4, lpattern(dash) lcolor(gray)) title(Average Arrears for SMS Group Consumers - Nov 2020 to Nov 2022 (Hoshangabad), size(small) margin(zero)) note("Note: High response consumers are taken as quartile 1 and low response consumers are taken as quartile 4." "The region between the red lines is the pre-period before treatment." "The region between the gray lines is the period of waiver.", size(vsmall)) graphregion(fcolor(white) ifcolor(white))

    I want to shade the regions between the grey vertical lines as well as the red vertical lines. I have been struggling to do the same.

    Looking forward to any help that can be provided!


    Click image for larger version

Name:	Screenshot 2023-04-26 234456.jpg
Views:	1
Size:	66.6 KB
ID:	1711362
    Last edited by Anjaney Singh; 26 Apr 2023, 12:21.

  • #2
    See

    https://journals.sagepub.com/doi/pdf...867X1601600315

    http://blog.stata.com/2020/02/13/add...series-graphs/

    Comment


    • #3
      Thank you! Nick Cox

      Comment

      Working...
      X