Showing posts with label mlabpos(). Show all posts
Showing posts with label mlabpos(). Show all posts

Oct 24, 2014

Random graphs (34): Country scatterplots

use ART.dta, replace

// Fix missing values
recode avgemtrans (-1 -3 = .)
recode emhum      (-1 = .)

// Calculate r-squared
qui regress avgemtrans emhum
local r2 = round(e(r2), .01) // Round coeff.

// Create first panel
twoway (scatter avgemtrans emhum, mlab(countrycode) mlabpos(0) msymbol(i)) ///
       (lfit avgemtrans emhum) ///
    , xlabel(, format(%6.1f)) ylabel(, format(%6.1f)) ///
    ytitle("Avg. no. of fresh non-donor embryos" "per fresh embryo transfer cycle") ///
    xtitle("Avg. level disagreement that" "embryo is a human being") ///
       legend(order(2 "Linear fit R{char 178} = `r2'") ring(0) pos(8)) ///
    name(figure2a, replace)

// Fix missing values
recode afford clonehelpinf (-1 = .)

// Listwise deletion to control y-axis range
preserve
keep if !missing(afford, clonehelpinf)

// Calculate r-squared    
regress afford clonehelpinf
local r2 = round(e(r2), .01) // Round coeff.

// Create second panel
twoway (scatter afford clonehelpinf, mlab(countrycode) mlabpos(0) msymbol(i)) ///
       (lfit afford clonehelpinf) ///
    , xlabel(, format(%6.1f)) ylabel(0 (5) 25, format(%6.1f)) ///
    ytitle("Affordability (net cost of a fresh ART cycle" "as % of annual disposable income)") ///
    xtitle("Avg. level disagreement with" "cloning to help infertile couples") ///
       legend(order(2 "Linear fit R{char 178} = `r2'") ring(0) pos(8)) ///
    name(figure2b, replace)
restore

// Create final Figure
graph combine figure2a figure2b, row(1)

Aug 9, 2012

Random graphs (1): Complex scatterplot


#delimit ;
twoway (scatter change2006_10 childcare if time == 2010
                                          & age == 2
                                     & duration == 3,
        mlab(geo2) mlabpos(0) msymbol(i)

     /* Make sure to use mlabpos(0), not mlabpos(central) */
     /* With mlabpos(central), all markers will be slightly off */

        yscale(range(-12 12))), // Slightly rescale y-axis
        xline(30) yline(0)    // Add horizontal and vertical lines
        xtitle("Performance"
           "(% of children under 3 in formal childcare in 2010)")
        ytitle("Progress"
           "(Percentage point change 2006{char 150}10)")
        text(-12 72 "Losing momentum")
        text( 12 70 "Moving further ahead")
        text(-12 10 "Falling further behind")
        text( 12  5 "Catching up")
        title("Progress towards the Barcelona targets,
               2006{c 150}2010")
        subtitle("Children under three years of age")
        note("Data: Eurostat database (ilc_caindformal),
              extraction date Aug 7, 2012", span);
        // 'span' makes sure that the note
        // starts on the very left side
#delimit cr