*this do-file replicates the figures in the submitted manuscript /***************************************** Figure 1 *****/ clear set obs 20 set seed 123245 //901 *generate data points forval i = 1/18 { gen x`i' = int(runiform()*100) local rand = runiform() if `rand' > .50 label var x`i' "Howdy, I am x`i'!" } sort x1 // check sortpreserve gen mylabel = round(runiform()*1000) chernoff, isize(x1) iangle(x2) ihor(x3) ivert(x4) psize(x5) ppos(x6) bcurv(x7) bdens(x8) /// bhor(x9) bvert(x10) hupper(x11) hlower(x12) hdark(x13) hslant(x14) fline(x15) nose(x16) /// msize(x17) mcurv(x18)ilabel(mylabel) order(mylabel) legend(3) xcomb(12) ycomb(14) graph export ex1.tif, width(4000) replace /*********************************************** Figure 2 *****/ use utility, clear tostring id, gen(ids) gen lbl = state + " / " + ids chernoff, bdens(kwcost) fline(nuclear) hdark(cover) iangle(load) isize(growth) mcurv(sales) /// hslant(return) nose(fuel) ilabel(lbl) saveall nocombine twoway pci 0 0 0 0, text(0 0 "Cluster 1", size(huge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("c1", replace) nodraw xsize(5) ysize(6) fysize(10) twoway pci 0 0 0 0, text(0 0 "Cluster 2", size(huge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("c2", replace) nodraw xsize(5) ysize(6) fysize(10) twoway pci 0 0 0 0, text(0 0 "Cluster 3", size(huge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("c3", replace) nodraw xsize(5) ysize(6) fysize(10) twoway pci 0 0 0 0, text(0 0 "Cluster 5", size(huge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("c5", replace) nodraw xsize(5) ysize(6) fysize(10) twoway pci 0 0 0 0, text(0 0 "Cluster 7", size(huge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("c7", replace) nodraw xsize(5) ysize(6) fysize(10) twoway pci 0 0 0 0, text(-1 0 "Cluster 4", size(huge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("c4", replace) nodraw xsize(5) ysize(6) twoway pci 0 0 0 0, text(-1 0 "Cluster 6", size(huge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("c6", replace) nodraw xsize(5) ysize(6) graph combine /// c1.gph c2.gph c3.gph c5.gph c7.gph /// FACE4.gph FACE1.gph FACE6.gph FACE5.gph FACE7.gph /// FACE10.gph FACE3.gph FACE22.gph FACE21.gph FACE15.gph /// FACE13.gph FACE9.gph c4.gph c6.gph FACE0.gph /// FACE20.gph FACE14.gph FACE8.gph FACE2.gph FACE0.gph /// FACE0.gph FACE18.gph FACE11.gph FACE12.gph FACE0.gph /// FACE0.gph FACE19.gph FACE16.gph FACE17.gph FACE0.gph /// , rows(8) scheme(s1mono) xsize(10) ysize(16) graph export ex2.tif, width(4000) replace /*********************************************** Figure 3 *****/ use flu, clear replace flu = 100-flu // invert the scale drop in L gen byte enlarge = 2 chernoff, is(flu) ia(flu) ih(flu) iv(flu) ps(flu) pp(flu) bc(flu) bd(flu) bh(flu) bv(flu) fl(flu) /// hu(flu) hl(flu) no(flu) ms(flu) mc(flu) hd(flu) hs(flu) ilab(lbl) isc(enlarge) rh rows(1) hspace(.5) graph export ex3a.tif, width(4000) replace use flu, clear replace flu = 100-flu // invert the scale drop in 1 gen byte enlarge = 2 chernoff, is(flu) ia(flu) ih(flu) iv(flu) ps(flu) pp(flu) bc(flu) bd(flu) bh(flu) bv(flu) fl(flu) /// hu(flu) hl(flu) no(flu) ms(flu) mc(flu) hd(flu) hs(flu) ilab(lbl) isc(enlarge) rh rows(1) hspace(.5) graph export ex3b.tif, width(4000) replace use flu, clear replace flu = 100-flu // invert the scale drop in L gen byte enlarge = 2 chernoff, is(flu) ia(flu) ih(flu) iv(flu) ps(flu) pp(flu) bc(flu) bd(flu) bh(flu) bv(flu) fl(flu) /// hu(flu) hl(flu) no(flu) ms(flu) mc(flu) hd(flu) hs(flu) ilab(lbl) isc(enlarge) rh rows(1) hspace(.5) gmin(0) gmax(100) graph export ex3c.tif, width(4000) replace use flu, clear replace flu = 100-flu // invert the scale drop in 1 gen byte enlarge = 2 chernoff, is(flu) ia(flu) ih(flu) iv(flu) ps(flu) pp(flu) bc(flu) bd(flu) bh(flu) bv(flu) fl(flu) /// hu(flu) hl(flu) no(flu) ms(flu) mc(flu) hd(flu) hs(flu) ilab(lbl) isc(enlarge) rh rows(1) hspace(.5) gmin(0) gmax(100) graph export ex3d.tif, width(4000) replace /***************************** clean up *****/ fs *.gph foreach f in `r(files)' { erase `f' } /********************************************* bonus example - not in article - plot min and max face *****/ *imagine the following dataset is a given clear set obs 24 set seed 5432123 *generate data points forval i = 1/17 { if `i' > 15 gen x`i' = round(runiform()*20 + 30) // [20, 50] else gen x`i' = round(runiform()*40 + 30) // [40, 70] } gen x18 = rnormal(1000000,200000) gen market = "San Francisco" replace market = "Houston" in 7/12 replace market = "Atlanta" in 13/18 replace market = "Seattle" in 19/L *generate title gen str13 mytitle = "" replace mytitle = "San Francisco" in 1 replace mytitle = "Houston" in 7 replace mytitle = "Atlanta" in 13 replace mytitle = "Seattle" in 19 gen byte year = 7 egen month = seq(), from(1) to(6) replace year = 8 if month > 4 replace month = 1 if month==5 replace month = 2 if month==6 tostring month, gen(quarter) replace quarter = "Q" + quarter *generate note tostring year, gen(yr) gen time = quarter + "/0" + yr ************ add and plot min and max faces set obs 26 summ x1 local min = r(min) // temp minimum score forval i = 1/17 { summ x`i' if r(min) < `min' local min = r(min) } forval i = 1/17 { replace x`i' = `min' in 25 replace x`i' = 75 in 26 } summ x18 replace x18 = r(min) in 25 replace x18 = r(max) in 26 *use a new label variable, do not use the time variable as label gen str7 mylbl = "" qui replace mylbl = "min" in 25 qui replace mylbl = "max" in 26 *save all faces chernoff, isize(x1) psize(x2) ppos(x3) iangle(x4) ihor(x5) ivert(x6) bcurv(x7) bdens(x8) bhor(x9) /// bvert(x10) nose(x11) msize(x12) mcurv(x13) hupper(x14) hlower(x15) hdark(x16) hslant(x17) fline(x18) /// ilabel(mylbl) order(market year quarter) rows(4) nocombine saveall *generate market name graphs twoway pci 0 0 0 0, text(0 0 "Atlanta market", size(vlarge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("atl", replace) nodraw xsize(5) ysize(6.8) fxsize(100) fysize(100) twoway pci 0 0 0 0, text(0 0 "Houston market", size(vlarge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("hou", replace) nodraw xsize(5) ysize(6.8) fxsize(100) fysize(100) twoway pci 0 0 0 0, text(0 0 "San Francisco" "market", size(vlarge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("san", replace) nodraw xsize(5) ysize(6.8) fxsize(100) fysize(100) twoway pci 0 0 0 0, text(0 0 "Seattle market", size(vlarge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("sea", replace) nodraw xsize(5) ysize(6.8) fxsize(100) fysize(100) *generate time graphs, shrink the y-axis twoway pci 0 0 0 0, text(0 0 "Q3/2007", size(vlarge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("q307", replace) nodraw xsize(5) ysize(6.8) fysize(10) twoway pci 0 0 0 0, text(0 0 "Q4/2007", size(vlarge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("q407", replace) nodraw xsize(5) ysize(6.8) fysize(10) twoway pci 0 0 0 0, text(0 0 "Q1/2008", size(vlarge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("q108", replace) nodraw xsize(5) ysize(6.8) fysize(10) twoway pci 0 0 0 0, text(0 0 "Q2/2008", size(vlarge)) lcolor(white) xscale(off) yscale(off) /// plotregion(color(white)) scheme(s1mono) saving("q208", replace) nodraw xsize(5) ysize(6.8) fysize(10) *combine all the graphs, can use either FACE0.gph or holes() graph combine /// q307.gph q407.gph q108.gph q208.gph /// /* FACE0.gph */ atl.gph FACE5.gph FACE6.gph FACE7.gph FACE8.gph /// FACE2.gph hou.gph FACE11.gph FACE12.gph FACE13.gph FACE14.gph /// FACE1.gph san.gph FACE17.gph FACE18.gph FACE19.gph FACE20.gph /// /* FACE0.gph */ sea.gph FACE23.gph FACE24.gph FACE25.gph FACE26.gph, /// holes(1 2 7 25) rows(5) plotregion(color(white)) scheme(s1mono) xsize(5) ysize(4.1) /***************************** clean up *****/ fs *.gph foreach f in `r(files)' { erase `f' }