Announcement

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

  • Shading area in two way graph for mulitple areas

    Hi,

    I am trying to shade multiple areas in my graph. Although i have read multiple forums and also this pdf, i am not able to find a perfect solution for my problem. This is also because i dont know how to efficiently select the time periods as upper and lower bounds.

    This is my code:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(credit_GDP_gap credit_GDP_ratio credit_GDP_ratio_HP) float(time year)
    . . 47.1 -49 1959
    . . 47.6 -48 1959
    . . 47.9 -47 1959
    . .   48 -46 1959
    . . 48.6 -45 1959
    . . 49.2 -44 1959
    . . 50.2 -43 1959
    . . 51.5 -42 1959
    . . 52.9 -41 1959
    . . 54.7 -40 1959
    . . 55.8 -39 1959
    . . 56.1 -38 1959
    . . 55.7 -37 1959
    . . 54.8 -36 1959
    . . 54.1 -35 1959
    . . 53.9 -34 1959
    . .   54 -33 1959
    . . 53.6 -32 1959
    . . 54.8 -31 1959
    . . 55.6 -30 1959
    . . 56.7 -29 1959
    . . 56.6 -28 1959
    . . 57.1 -27 1959
    . . 57.3 -26 1959
    . .   58 -25 1959
    end
    format %tq time
    This is my code for the graph:

    twoway (line credit_GDP_gap time) (line credit_GDP_ratio time, yaxis(2) lcolor(red) lpattern(dash)), xtitle(year-quarter) title(evolution of credit in the united states)

    Click image for larger version

Name:	Screenshot 2023-06-16 at 17.28.03.png
Views:	1
Size:	77.5 KB
ID:	1717388


    Now i want to shade for mulitple areas: for example shade between 1980q1 and 1983q1 and 1990q1 and 1983q1. Do i use the rarea option for this and how do i properly set it up? Do i use minimum and maximum and do i use it multiple times or how could i do this efficiently?

    Many Thanks in advance!

    Timme




Working...
X