Announcement

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

  • plotting several graphs once

    Dear profs and colleagues,

    there are 3 variables:
    immi: the share of immigrant
    region: regions
    year: 2010- 2019
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str8 region int year double immi
    "Norte"    2010  1.3
    "Centro"   2010  2.7
    "Lisboa"   2010  7.9
    "Alentejo" 2010  3.5
    "Algarve"  2010   16
    "Açores"  2010  1.4
    " Madeira" 2010  2.5
    "Norte"    2011  1.3
    "Centro"   2011  2.7
    "Lisboa"   2011  7.7
    "Alentejo" 2011  3.6
    "Algarve"  2011 15.3
    "Açores"  2011  1.4
    " Madeira" 2011  2.5
    "Norte"    2012  1.2
    "Centro"   2012  2.6
    "Lisboa"   2012  7.5
    "Alentejo" 2012  3.5
    "Algarve"  2012 13.9
    "Açores"  2012  1.3
    " Madeira" 2012  2.3
    "Norte"    2013  1.2
    "Centro"   2013  2.4
    "Lisboa"   2013  7.3
    "Alentejo" 2013  3.3
    "Algarve"  2013   13
    "Açores"  2013  1.3
    " Madeira" 2013  2.2
    "Norte"    2014  1.2
    "Centro"   2014  2.4
    "Lisboa"   2014  7.2
    "Alentejo" 2014  3.2
    "Algarve"  2014 12.7
    "Açores"  2014  1.3
    " Madeira" 2014  2.2
    "Norte"    2015  1.2
    "Centro"   2015  2.3
    "Lisboa"   2015    7
    "Alentejo" 2015  3.2
    "Algarve"  2015 12.9
    "Açores"  2015  1.4
    " Madeira" 2015  2.2
    "Norte"    2016  1.2
    "Centro"   2016  2.4
    "Lisboa"   2016    7
    "Alentejo" 2016  3.3
    "Algarve"  2016   14
    "Açores"  2016  1.4
    " Madeira" 2016  2.4
    "Norte"    2017  1.4
    "Centro"   2017  2.6
    "Lisboa"   2017  7.2
    "Alentejo" 2017  3.4
    "Algarve"  2017 15.1
    "Açores"  2017  1.4
    " Madeira" 2017  2.7
    "Norte"    2018  1.7
    "Centro"   2018  2.8
    "Lisboa"   2018  8.4
    "Alentejo" 2018  3.7
    "Algarve"  2018 16.9
    "Açores"  2018  1.5
    " Madeira" 2018    3
    "Norte"    2019  2.1
    "Centro"   2019  3.5
    "Lisboa"   2019 10.4
    "Alentejo" 2019  4.5
    "Algarve"  2019   20
    "Açores"  2019  1.6
    " Madeira" 2019  3.4
    end
    I need to plot graphs that show immi (the share of immigrants) across regions during the period 2010-2019. I mean for each year separately. It will be 10 graphs but all in one code.

    Any ideas are appreciated.

    Cheers,
    Paris

  • #2
    Plotting the profile of immigration over time for each region is more intuitive to read. The code below is a minimal starting point.

    Code:
    sc immi year , by(region) c(l) sort(region year)

    Comment


    • #3
      I agree strongly with Leonardo Guizzetti and would go further. If you are showing each region, you have space to show the others as context. And the default alphabetical order by region name helps no-one, or so I suspect. I used fabplot and myaxis from the Stata Journal.

      Code:
      replace region = trim(region) 
      myaxis REGION=region, sort(mean immi) descending
      fabplot line immi year, by(REGION) front(connected) xla(2010 "2010" 2012(2)2020, format(%tyYY))
      I am away from my uisual computer and am not using Stata 18. Log scale also seems like a strong runner.

      Click image for larger version

Name:	rira.png
Views:	1
Size:	57.6 KB
ID:	1717923


      Comment


      • #4
        Thank you so much Nick and Leonardo.

        Comment


        • #5
          Originally posted by Nick Cox View Post
          I agree strongly with Leonardo Guizzetti and would go further. If you are showing each region, you have space to show the others as context. And the default alphabetical order by region name helps no-one, or so I suspect. I used fabplot and myaxis from the Stata Journal.

          Code:
          replace region = trim(region)
          myaxis REGION=region, sort(mean immi) descending
          fabplot line immi year, by(REGION) front(connected) xla(2010 "2010" 2012(2)2020, format(%tyYY))
          I am away from my uisual computer and am not using Stata 18. Log scale also seems like a strong runner.

          [ATTACH=CONFIG]n1717923[/ATTACH]
          Is it possible to change the colors of the front lines for a given subgroup? Let's say "Norte" is a treated region and I want to make the front line green or red in the graph. I am unable to do it with fabplot.

          Comment


          • #6
            Noman Ahmad #5 This is not currently supported.

            Comment


            • #7
              Originally posted by Nick Cox View Post
              Noman Ahmad #5 This is not currently supported.
              Thanks, Nick!

              Comment

              Working...
              X