一款简洁的Stata图形模板:qlean

德国哥廷根大学(University of Göttingen)的Yi Qu开发了一款简洁的Stata图形模板qlean,托管在Github上,地址为https://github.com/rangerqu/qlean。

该文件夹下包含qlean和qleanmono两个图形模板,GitHub 文件的原链接分别为:
https://github.com/rangerqu/qlean/blob/master/scheme-qlean.scheme
https://github.com/rangerqu/qlean/blob/master/scheme-qleanmono.scheme

相应地单个文件下载链接分别为:
https://raw.githubusercontent.com/rangerqu/qlean/master/scheme-qlean.scheme
https://raw.githubusercontent.com/rangerqu/qlean/master/scheme-qleanmono.scheme

即,将 github.com 替换为 raw.githubusercontent.com,并去除 /blob

将Stata图形模板安装到 PLUS 目录,Stata代码如下:


local dir : sysdir PLUS
disp  "`dir'"
disp "`dir's/"
copy https://raw.githubusercontent.com/rangerqu/qlean/master/scheme-qlean.scheme "`dir's/",replace
copy https://raw.githubusercontent.com/rangerqu/qlean/master/scheme-qleanmono.scheme "`dir's/",replace

查看目前可用的Stata图形模板,Stata代码如下:


graph query, schemes

可以看出,qlean和qleanmono出现在Available schemes列表中了。

选择需要预览的Stata图形模板,如Stata自带的s2color和s2mono及刚才安装的qlean和qleanmono,用循环挨个绘图,最后合并,Stata代码如下:


sysuse uslifeexp, clear
local schemes s2color s2mono qlean qleanmono
*先设置局部宏plots为空,可以不设置;若是数值型,类似local counter = 0
local plots
foreach scheme of local schemes {
    line le_female year|| line le_male year, legend(row(1) position(6) ring(1)) title(`scheme') scheme(`scheme') saving(`scheme',replace)
*将循环结果叠加到局部宏plots,若是数值型,类似local counter = `counter' + 1
*局部宏后也可加引号,结果一样:local plots "`plots' `scheme'.gph"
    local plots `plots' `scheme'.gph
}
graph combine `plots'

完,本文内容交流请移步: