Announcement

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

  • Threeway scatterplot

    Stata users, I want to make a three-way scatter plot of FDI, Trade, and GDP. This is to visualize how the countries rank on these three variables.

  • #2
    Stata graphs are primarily two-dimensional, but you can refer to the following Stata tip on incorporating a third dimension in a 2D-plot: https://journals.sagepub.com/doi/epd...867X0500500412. Below is a scatter plot with weighted markers, which is not covered in the tip. This graphic uses the size of the markers to represent a third dimension, which is a quantitative variable such as log aggregate GDP (size of economy), market value (firm size), or log population (country size). Here is an illustration using the census dataset.

    Code:
    sysuse census, clear
    tw scatter marriage divorce if marriage>75000 [aw= pop], ms(oh)|| ///
    scatter marriage divorce if marriage>75000, ms(none) mlab(state2) mlabpos(0) ||, ///
    note(Marker sizes represent population of state) leg(off)
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	30.4 KB
ID:	1760769

    Comment


    • #3
      Thank you Andrew

      Comment


      • #4
        Not what you asked for, but consider

        0. Using log scale!

        1. Scatter plot matrix, with here just 3 scatter plots.

        2. Something quite different from scatter plots.

        Here I compare 10 companies on 3 measures, but take logarithms first and scale to [0, 1].

        Company 1 is always top on each measure and company 10 always bottom for 1954.

        This design allows you to see identifiers -- but will be of limited use if you have hundreds of countries.

        Code:
        webuse grunfeld, clear 
        
        foreach v in invest mvalue kstock { 
            gen ln`v' = ln(`v')
            su ln`v' if year == 1954, meanonly 
            gen show`v' = (ln`v' - r(min)) / (r(max) - r(min))
            _crcslbl show`v' `v'
        }
        
        graph dot (asis) show* if year==1954, over(company, sort(1) descending) ///
        marker(1, ms(Oh) msize(large)) marker(2, ms(+) msize(large)) marker(3, ms(Th) msize(large)) ysc(r(-0.05 1.05)) ///
        ytitle(first take logarithms; then rescale each variable to [0, 1]) subtitle(1954) legend(row(1) pos(12)) ///
        l1title(Company)


        Click image for larger version

Name:	ranking_on_3_variables.png
Views:	1
Size:	51.2 KB
ID:	1760867

        Comment

        Working...
        X