Announcement

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

  • graphing

    Dear All,
    Greetings,
    I want to graph a two-way barch chart. my period is from 200q1 to 2023q3. I labeled my policy mix variable to
    ***label define policy mix 1 "AMPF" 2 "PMAF" 3 "AMAF"
    ****label values policymix policymix
    However, I can't generate the graph as I want. I have attached the figure I want to generate.
    Could you please help in generating the code. Thanks


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float quarter byte policymix
    160 1
    161 1
    162 1
    163 1
    164 1
    165 1
    166 1
    167 1
    168 2
    169 2
    170 2
    171 2
    172 2
    173 2
    174 2
    175 2
    176 2
    177 2
    178 2
    179 2
    180 2
    181 1
    182 1
    183 1
    184 1
    185 1
    186 1
    187 1
    188 1
    189 1
    190 1
    191 1
    192 1
    193 1
    194 1
    195 1
    196 2
    197 2
    198 2
    199 2
    200 2
    201 2
    202 2
    203 2
    204 2
    205 2
    206 2
    207 2
    208 2
    209 2
    210 2
    211 2
    212 2
    213 2
    214 2
    215 2
    216 2
    217 2
    218 2
    219 2
    220 2
    221 2
    222 2
    223 2
    224 2
    225 2
    226 2
    227 2
    228 1
    229 1
    230 1
    231 1
    232 1
    233 1
    234 1
    235 1
    236 1
    237 1
    238 1
    239 1
    240 3
    241 3
    242 3
    243 3
    244 3
    245 3
    246 3
    247 3
    248 2
    249 2
    250 2
    251 2
    252 2
    253 2
    254 2
    255 2
    end
    format %tq quarter
    label values policymix policymix
    label def policymix 1 "AMPF", modify
    label def policymix 2 "PMAF", modify
    label def policymix 3 "AMAF", modify
    Attached Files

  • #2
    See my paper or the Stata blog post on shading zones

    Comment


    • #3
      Dear Nick Cox,
      Thank you for the suggestion. However, I can't generate a shaded zone following the codes.
      I run these two codes:
      generate upper = 1
      twoway area upper policymix if inrange(policymix , 2000q1, 2001q4), bcolor(gs14) base(10) || ///
      area upper policymix if inrange(policymix , 2002q1, 2005q1), bcolor(yellow) base(10) || ///
      area upper policymix if inrange(policymix , 2005q2, 2008q4), bcolor(red) base(10) || ///
      area upper policymix if inrange(policymix , 2009q1, 2016q4), bcolor(yellow) base(10) || ///
      area upper policymix if inrange(policymix , 2017q4, 2019q4), bcolor(yellow) base(10) || ///
      area upper policymix if inrange(policymix , 2020q1, 2021q4), bcolor(yellow) base(10) || ///
      area upper policymix if inrange(2022q1, 2023q4), bcolor(yellow) plotregion(margin(zero))


      ****
      generate upper = 1
      local barcall upper policymix if inrange(policymix, 2000q1, 2001q4) | inrange(policymix, 2002q1, 2005q1) | inrange(policymix, 2005q2, 2008q4 ), bcolor(gs14) base(10)
      twoway bar `barcall“

      Comment


      • #4
        Stata won't read 2002q1 as a number, for example. yq(2002, 1) should work. There are other ways to do it.

        Comment

        Working...
        X