Announcement

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

  • Drawing the yearly production of 16 region in one graph

    Hello Stata users;

    I have this data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str15 year int(year2012 year2013 year2014 year2015 year2016 year2017 year2018 year2019 year2020)
    "NABEUL"           2500  2500  2500  2500  2500  2500  2500  2200  2200
    "DAR CHAABANE"     2500  2500  2500  2500  2500  2500  2800  2200  2200
    "BENI KHIAR"       2250  2250  2250  2250  2240  2240  2500  2500  2500
    "KORBA"            8730  8730  8730  7730  7200  7200  7500  7500  7500
    "MENZEL TEMIME"    9400  9400  9400  9400 14900 15500 15650 16500 19000
    "EL MIDA"         14900 13900 13900 14900  8200  8500  8650  9200  9200
    "KELIBIA"          9500  9500  9500  9500  9200 10000 10000 10000 10000
    "HAMMAM GUEZAZE"   6500  6500  6500  6500  5500  6000  6500  6500  6500
    "EL HAOUARIA"      9550  9550  9550  9550  8590  8590  8590  9500 12000
    "TAKELSA"          3800  3800  3800  3800  3800  3800  3900  3900  3900
    "SOLIMAN"          5050  5050  5050  5050  4050  4850  4850  4850  4850
    "MENZEL BOUZELFA"  6950  6950  6950  6950  6950  6950  6950  6950  6950
    "BENI KHALLED"     4600  4600  4600  4600  4600  4600  4800  4800  4800
    "GROMBALIA"        5950  5950  5950  5950  5950  5950  5950  5000  5000
    "BOU ARGOUB"       2280  2280  2280  2280  2280  2280  2320  2000  2000
    "HAMMAMET"         1540  1540  1540  1540  1540  1540  1540  1400  1400
    end
    What I wanna do with this data is draw a graph that shows, for each region (NABEUL, DAAR CHAABEN, ...), the evolution of the yearly production of oil.
    I thought about having a 16 line graph, but then I guess the graph would be crowded, but at the same time, I would love to have all 16 regions in one graph, just for comparaison reasons, I also thought about drawing a bar graph, but I don't think that's the best solution.

    Any ideas and code suggestions please?

    Thanks!

  • #2
    I think the results with all 16 lines on a single plot are just unreadable. I would do 16 small repeats within a single graph.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str15 year int(year2012 year2013 year2014 year2015 year2016 year2017 year2018 year2019 year2020)
    "NABEUL"           2500  2500  2500  2500  2500  2500  2500  2200  2200
    "DAR CHAABANE"     2500  2500  2500  2500  2500  2500  2800  2200  2200
    "BENI KHIAR"       2250  2250  2250  2250  2240  2240  2500  2500  2500
    "KORBA"            8730  8730  8730  7730  7200  7200  7500  7500  7500
    "MENZEL TEMIME"    9400  9400  9400  9400 14900 15500 15650 16500 19000
    "EL MIDA"         14900 13900 13900 14900  8200  8500  8650  9200  9200
    "KELIBIA"          9500  9500  9500  9500  9200 10000 10000 10000 10000
    "HAMMAM GUEZAZE"   6500  6500  6500  6500  5500  6000  6500  6500  6500
    "EL HAOUARIA"      9550  9550  9550  9550  8590  8590  8590  9500 12000
    "TAKELSA"          3800  3800  3800  3800  3800  3800  3900  3900  3900
    "SOLIMAN"          5050  5050  5050  5050  4050  4850  4850  4850  4850
    "MENZEL BOUZELFA"  6950  6950  6950  6950  6950  6950  6950  6950  6950
    "BENI KHALLED"     4600  4600  4600  4600  4600  4600  4800  4800  4800
    "GROMBALIA"        5950  5950  5950  5950  5950  5950  5950  5000  5000
    "BOU ARGOUB"       2280  2280  2280  2280  2280  2280  2320  2000  2000
    "HAMMAMET"         1540  1540  1540  1540  1540  1540  1540  1400  1400
    end
    
    rename year region
    rename year* oil_production*
    reshape long oil_production, i(region) j(year)
    encode region, gen(n_region)
    
    twoway line oil_production year, by(region) ylabel(, angle(0))

    Comment


    • #3
      Aziz Essouaied The advice to reshape long when you have time series in wide layout has been given repeatedly in previous threads you started.

      I found these quickly and then stopped counting.

      https://www.statalist.org/forums/for...for-24-regions

      https://www.statalist.org/forums/for...s-with-19-line

      https://www.statalist.org/forums/for...other-variable


      Time to see a pattern there!

      Comment

      Working...
      X