{smcl} {* 18May2009}{...} {cmd:help wfex_graphs}: Examples of graphs {hline} {title:List of examples} 1. Creating a graph from data in a matrix. 2. Scatterplots for all pairs of variables. 3. Adding provenance captions to a graph. {title:1. Creating a graph from data in a matrix} * Create variables from columns of matrix {bf:stats} where * the column names of the matrix are used to name the variables svmat stats, names(col) * Create a graph of bic statistics against the root of the transformation * used in the model twoway (connected bic root, msymbol(circle)), /// ytitle(BIC statistic) ylabel(1700(10)1750) /// xtitle(Root transformation of articles) xlabel(1(1)9) /// caption("wf7-matrix-plot.do \ jsl 2008-04-11",size(vsmall)) {title:2. Scatterplots for all pairs of variables} * The {bf:graph matrix} command creates a single graph with scatterplots * for all pairs of variables. graph matrix job phd ment art cit fem fel, /// jitter(3) half msymbol(circle_hollow) * To create an individual graph for each pair of variables, * you can use a double {bf:forvalues} loop. local varlist "phd job ment art cit fem fel" local nvars : word count `varlist' forvalues y_varnum = 1/`nvars' { local y_var : word `y_varnum' of `varlist' local y_lbl : variable label `y_var' label var `y_var' "`y_var': `y_lbl'" local x_start = `y_varnum' + 1 forvalues x_varnum = `x_start'/`nvars' { local x_var : word `x_varnum' of `varlist' local x_lbl : variable label `x_var' label var `x_var' "`x_var': `x_lbl'" scatter `y_var' `x_var', msymbol(circle_hollow) jitter(8) /// ylabel(, grid) xlabel(, grid) aspectratio(1) graph export wf6-review-jobphd-`y_var'-`x_var'.png, replace label var `x_var' "`x_lbl'" } } {title:3. Adding provenance captions to graphs} * The local "cap" contains the information to appear as a caption to the graph. local cap "wf7-caption.do \ jsl 2008-04-09" * The {bf:caption} option is used to add the information to the graph. twoway (line art_root2 art_root3 art_root4 art_root5 articles, /// lwidth(medium)), ytitle(Number of Publications to the k-th Root) /// yscale(range(0 8.)) legend(pos(11) rows(4) ring(0)) /// caption(`cap', size(vsmall)) {p2colset 5 12 12 2} {title:Also see} Chapter 4 of the {it:Workflow} book; {helpb graph}; {helpb forvalues}; {helpb wf:Workflow} INCLUDE help wf_footer