Stata如何绘制万花尺?

巴德学院利维经济研究所的Fernando Rios-Avila开发了Stata社区命令spirograph,用以绘制万花尺。

该Stata社区命令spirograph目前没有安装命令和帮助手册,所以直接下载GitHub里的spirograph.ado文件,Stata命令如下:


copy https://raw.githubusercontent.com/friosavila/stataviz/blob/main/spirograph/spirograph.ado /// C:\Users\Administrator\ado\plus\s/


Stata社区命令spirograph的命令使用格式:


spirograph, r(numlist) /// this represent the radious r
s(numlist) /// and this the speed of change or the angle gamma
rotation(#) /// you can indicate how many "rotations" you want to use
adjust(#) /// and how many points per rotation to use. (higher=smoother)
lwidth(#) /// width of the line
default   /// to set default look
color(color list) /// to provide a list of colors, if necessary

You can use the options r() and s() up to 9 times, so you can produce up to 9 different drawings in the same graph.

绘制上图的Stata代码如下:


spyrograph, r(1 .3 .35 ) s(1 6.05 2 )  ///
			 r(1 .3 .35 ) s(1 6.05 3 )  ///
			 r(2 .3 .35 ) s(1 7.05 4 ) ///
			 r(3 .3 .35 ) s(1 7.05 5 ) ///
			 r(4 .3 .35 ) s(1 7.05 6 ) rotation(20) adjust(5) default lwidth(.1)


绘制上图的Stata代码如下:

*安装社区命令schemepack,获得white_tableau等多种图形模板
ssc install schemepack, replace
set scheme white_tableau
spirograph, r(5 .43 1.35 ) s(1 6.05 1.95 )  ///
			rotation(20) adjust(5) default lwidth(.1)


绘制上图的Stata代码如下:


spirograph, r(5 .5   1  )  s(1 6   12.05   )  ///
			r(5 1.5   1 )  s(1 6   12.05   )  ///
			r(2 .5   1  )  s(2 6   11.05   )  ///
			rotation(20) adjust(5) default lwidth(.1) color(navy)