stata连享会

Stata绘图: 添加虚线网格线

2018-11-08  本文已影响263人  stata连享会

作者:连玉君 (知乎 | 简书 | 码云)

Stata连享会 精彩推文1 || 精彩推文2

简介

有些中文期刊 (如《统计研究》) 要求图片中的网格线为虚线,而不是 Stata 默认的浅灰色实线。我们可以使用 yline() 选项自行修改。

Stata 范例

代码

cd "D:\stata15\ado\personal\Jianshu\graph_虚线网格线"

*-数据预处理
. sysuse "auto.dta", clear
. gen t = _n + 1999
. keep in 1/10
. replace price = price/100

*-图形模板
. set scheme s1mono  
. twoway connected price t
. graph export "Fig1_无网格线.png", replace

. twoway connected price t, ///
         ylabel(, grid) 
. graph export "Fig2_添加网格线_默认.png", replace

. twoway connected price t, ///
         ylabel(, nogrid) ///
         yline(40(20)100, lp(dash) lc(black*0.4)) 
. graph export "Fig3_添加网格线_虚线.png", replace 

输出效果

Fig1_无网格线.png Fig2_添加网格线_默认.png Fig3_添加网格线_虚线.png

关于我们

联系我们

往期精彩推文


欢迎加入Stata连享会(公众号: StataChina)
上一篇 下一篇

猜你喜欢

热点阅读