Announcement

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

  • Help needed to circle out observations in a scatter plot

    Hi,

    I need help in circling out specific observations in my scatterplot. Here is my data and scatter plot:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(Overall_digital Trust_safety) int Year str12 Country
     1.4911944748969637 62.1 2018 "CHN"      
     1.1213408324666971    . 2018 "Hong Kong"
     -.9354383366385858 65.1 2018 "IND"      
     -1.170759219326978 65.9 2018 "IDN"      
      .4900689245217592 47.9 2018 "JPN"      
      .0743814016041916 56.5 2018 "MYS"      
     -.9019645756671696 56.7 2018 "PHL"      
     1.3019748954571109 49.8 2018 "SGP"      
        .59285067651566 47.7 2018 "ROK"      
     -.8939165934565277 35.1 2018 "THA"      
    -1.1697324803731215 67.4 2018 "VNM"      
     1.4633771560661124 73.2 2019 "CHN"      
     1.3356631016510268    . 2019 "Hong Kong"
     -.5816092928110765 70.7 2019 "IND"      
    -1.1366984242244103 69.5 2019 "IDN"      
      .8734172000204578 44.1 2019 "JPN"      
     .21963797533267906 63.6 2019 "MYS"      
     -.8669008987190485   56 2019 "PHL"      
      1.417392252169481 52.6 2019 "SGP"      
      .9159432918807312 46.2 2019 "ROK"      
    -1.0820484226481373 57.3 2019 "THA"      
     -.9675688685359461 66.5 2019 "VNM"      
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
                      .    .    . ""         
    end
    I used the following code to produce the chart:

    Code:
    separate Overall_digital, by(Year)
    correlate Overall_digital Trust_safety  if  !inlist(Country,"Hong Kong", "CHN") // 2018 and 2019
    local rho: display %3.2f r(rho)
    sum Trust_safety 
    local min = r(min)
    local max = r(max)
    graph twoway (scatter Overall_digital2018 Trust_safety, mlabel(Country)) ///
            (scatter Overall_digital2019 Trust_safety, mlabel(Country)) || (lfit Overall_digital Trust_safety if  !inlist(Country,"Hong Kong","CHN"), range(`min' 80)), note(Note: Line of best fit and correlation coefficient exclude China and Hong Kong) text(0 35 "{&rho} = `rho'") ytitle(Overall Digital Index score) xtitle(Trust & Safety score) legend(label(1 2018) label(2 2019))
    I intend to circle the 2 observations labeled "CHN" and not sure how to do it. Does anyone has a solution for this?

    Thanks!
    Attached Files
Working...
X