graph3d——绘制立体的小心心

graph3d——绘制立体的小心心

本文的代码来自贝林·查韦斯的个人网站:http://www.belenchavez.com/data-blog/happy-valentines-day-stata-style作为学习,我还进行了适当的改造。

原始代码

Stata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
clear all
set obs 463
gen t = .
local c = 1
forv i = 0(0.05)`=2`c(pi)''{
replace t = `i' in `c'
local ++c
}

gen x = 16*sin(t)^3
gen y = 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
gen mlab = "<3"
graph3d x y t , colorscheme(cr) scale(3) markeroptions(mlab(mlab))
gr export 小心心1.png, replace

改进1

Stata
1
2
graph3d x y t , colorscheme(cr) scale(3) markeroptions(mlab(mlab) ms(i))
gr export 小心心2.png, replace

改进2

Stata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
clear all
set obs 463
gen t = .
local c = 1
forv i = 0(0.05)`=2`c(pi)''{
replace t = `i' in `c'
local ++c
}

gen x = 16*sin(t)^3
gen y = 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
gen mlab = "❤️"
graph3d x y t , colorscheme(cr) scale(3) markeroptions(mlab(mlab) mlabsize(small) ms(i))
gr export 小心心3.png, replace

改进3

Stata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
clear all
set obs 463
gen t = .
local c = 1
forv i = 0(0.05)`=2`c(pi)''{
replace t = `i' in `c'
local ++c
}

gen x = 16*sin(t)^3
gen y = 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
gen mlab = "🍎"
graph3d x y t , colorscheme(cr) scale(3) markeroptions(mlab(mlab) ms(i))
gr export 小心心4.png, replace

改进4

Stata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
clear all
set obs 463
gen t = .
local c = 1
forv i = 0(0.05)`=2`c(pi)''{
replace t = `i' in `c'
local ++c
}

gen x = 16*sin(t)^3
gen y = 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
gen mlab = "🌹"
graph3d x y t , colorscheme(cr) scale(3) markeroptions(mlab(mlab) ms(i))
gr export 小心心5.png, replace

改进5

Stata
1
2
3
4
5
6
7
8
9
10
11
12
13
14
clear all
set obs 463
gen t = .
local c = 1
forv i = 0(0.05)`=2`c(pi)''{
replace t = `i' in `c'
local ++c
}

gen x = 16*sin(t)^3
gen y = 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t)
gen mlab = "😆"
graph3d x y t , colorscheme(cr) scale(3) markeroptions(mlab(mlab) ms(i))
gr export 小心心6.png, replace

# Stata

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×