Announcement

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

  • Scatter Plot, Twoway plot

    I am making a scatter plot of changes in GDP vs changes in the ratio of old-age dependency panel data. How can I do it?
    Thank you!
    Last edited by John Kab; 27 May 2018, 13:59.

  • #2
    Code:
    help scatter
    if this is not sufficient, please read the FAQ on how to ask questions that get useful answers

    Comment


    • #3
      It's not sufficient. To be clear, I want a plot of changes in GDP vs changes in the ratio of old-age dependency. Here's my code

      twoway (scatter change_gdp change_dependency if sample_oecd!=1 , msize(*2) msymbol(circle) mfcolor(ltblue) mlcolor(black)) ///
      (scatter change_gdp change_dependency if sample_oecd!=1 & (change_gdp>2|change_dependency>.2), mlabel(countrycode) msize(*2) msymbol(circle) mfcolor(ltblue) mlcolor(black)) ///
      (scatter change_gdp change_dependency if sample_oecd==1 & cname_ifr!="Japan" , mlabel(countrycode) msize(*2) msymbol(diamond) mfcolor(dkorange) mlcolor(black)) ///
      (scatter change_gdp change_dependency if cname_ifr=="Japan", mlabel(countrycode) msize(*2) msymbol(triangle) mfcolor(cranberry) mlcolor(black)) ///
      (lfit change_gdp change_dependency, lcolor(navy)), ///
      ylabel(#6, glwidth(thin) glcolor(gs12)) ///
      legend(on cols(2) order(1 "All countries except OECD" 3 "OECD countries" )) ytitle("Change in GDP per capita from 1990 to 2015") xtitle("Change in the old age dependecy ratio") ///
      graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white) ) plotregion(fcolor(white) ifcolor(white) lcolor(white) lwidth(none) ilcolor(white) )

      Comment


      • #4
        I can't yet see an answerable question here. You don't give example data. On the face of it the code gives plots of change_gdp versus change_dependency. but there is no graph example either. So what's wrong?

        Comment


        • #5
          Sorry! Please find attached the graph that I want to replicate and the data.

          twoway (scatter change_gdp change_dependency if sample_oecd!=1 , msize(*2) msymbol(circle) mfcolor(ltblue) mlcolor(black)) ///
          (scatter change_gdp change_dependency if sample_oecd!=1 & (change_gdp>2|change_dependency>.2), mlabel(countrycode) msize(*2) msymbol(circle) mfcolor(ltblue) mlcolor(black)) ///
          (scatter change_gdp change_dependency if sample_oecd==1 & cname_ifr!="Japan" , mlabel(countrycode) msize(*2) msymbol(diamond) mfcolor(dkorange) mlcolor(black)) ///
          (scatter change_gdp change_dependency if cname_ifr=="Japan", mlabel(countrycode) msize(*2) msymbol(triangle) mfcolor(cranberry) mlcolor(black)) ///
          (lfit change_gdp change_dependency, lcolor(navy)), ///
          ylabel(#6, glwidth(thin) glcolor(gs12)) ///
          legend(on cols(2) order(1 "All countries except OECD" 3 "OECD countries" )) ytitle("Change in GDP per capita from 1990 to 2015") xtitle("Change in the old age dependecy ratio") ///
          graphregion(fcolor(white) ifcolor(white) lcolor(white) ilcolor(white) ) plotregion(fcolor(white) ifcolor(white) lcolor(white) lwidth(none) ilcolor(white) )
          Attached Files
          Last edited by John Kab; 28 May 2018, 07:53.

          Comment


          • #6
            I gather something like - scatter var1 var2, mlabel(var3) - may do the trick.
            Last edited by Marcos Almeida; 28 May 2018, 09:39.
            Best regards,

            Marcos

            Comment


            • #7
              It doesn't work

              Comment


              • #8
                Please take a look at the FAQ. There you’ll find how to share data/command/output. This is the best approach to reap a helpful reply. Saying ‘it doesn’t work’, as also underscored in the FAQ, is not much informative.
                Best regards,

                Marcos

                Comment


                • #9
                  Thank you! I have already solved the problem.

                  Comment

                  Working...
                  X