- //在图像中添加背景
- //转化地址: http://www.text-image.com/convert/ascii.html
- //set width to 500 转化时特别注意的地方
- // 下载后保存到当前工作路径(输入cd/pwd),本例命名为car ascii to text big.txt
- set more off
- infix str1 a1-a500 1-500 using "car ascii to text big.txt", clear
- //hexdump may be needed to look for unexpected characters
- //hexdump "D:\StataMP\ado\personal\data\car ascii to text big.txt", tabulate
- //scaling y axis picture data and reversing
- generate y=90+((_N-_n+1)*1)
- reshape long a, i(y) j(col)
- //replacing characters with numbers
- replace a="1" if a=="+"
- replace a="2" if a=="-"
- replace a="3" if a=="."
- replace a="4" if a=="/"
- replace a="5" if a==":"
- replace a="6" if a=="-"
- replace a="7" if a=="M"
- replace a="8" if a=="N"
- replace a="9" if a=="`"
- replace a="10" if a=="d"
- replace a="11" if a=="h"
- replace a="12" if a=="m"
- replace a="13" if a=="o"
- replace a="14" if a=="s"
- replace a="15" if a=="y"
- //scaling x axis picture data
- replace col=col/10
- merge 1:1 _n using "D:\StataMP\ado\base/a/auto.dta" //<--------根据需要改变
- local size="tiny"
- twoway ///
- (scatter y col if a=="1" ,msymbol(circle) ///
- mcolor("0 0 0*.20") msize(`size') ) ///
- (scatter y col if a=="2" ,msymbol(circle) ///
- mcolor("255 255 255*.2") msize(`size')) ///
- (scatter y col if a=="3" ,msymbol(circle) ///
- mcolor("255 0 0*.2") msize(`size') ) ///
- (scatter y col if a=="4" ,msymbol(circle) ///
- mcolor("0 0 255*.2") msize(`size') ) ///
- (scatter y col if a=="5" ,msymbol(circle) ///
- mcolor("0 0 255*.2") msize(`size') ) ///
- (scatter y col if a=="6" ,msymbol(circle) ///
- mcolor("255 255 0*.2") msize(`size') ) ///
- (scatter y col if a=="7" ,msymbol(circle) ///
- mcolor("0 255 255*.2") msize(`size') ) ///
- (scatter y col if a=="8" ,msymbol(circle) ///
- mcolor("255 0 255*.2") msize(`size') ) ///
- (scatter y col if a=="9" ,msymbol(circle) ///
- mcolor(white) msize(`size') ) ///
- (scatter y col if a=="10",msymbol(circle) ///
- mcolor(orange*.2) msize(`size') ) ///
- (scatter y col if a=="11",msymbol(circle) ///
- mcolor(brown*.2) msize(`size') ) ///
- (scatter y col if a=="12",msymbol(circle) ///
- mcolor(sand*.2) msize(`size') ) ///
- (scatter y col if a=="13",msymbol(circle) ///
- mcolor(black*.2) msize(`size') ) ///
- (scatter y col if a=="14",msymbol(circle) ///
- mcolor(black*.2) msize(`size') ) ///
- (scatter y col if a=="15",msymbol(circle) ///
- mcolor(black*.2) msize(`size') ) ///
- (scatter length mpg) ///
- (lfit length mpg) ///
- ,yscale( range(100 250)) ///
- ytitle(Length ins.) xtitle(mpg) ///
- title(Mpg v Length) legend(off)
- exit


雷达卡
京公网安备 11010802022788号







