Stata中的饼图

Stata中的饼图

本文是旧笔记的总结。介绍了Stata中饼图的用法以及一些饼图相关的命令使用。

饼图的类型

Stata
1
2
vguse allstates, clear
gr pie pop, over(division)

Stata
1
2
vguse nlsw, clear
gr pie, over(occ7)

Stata
1
gr pie, over(union) missing

排序

noclockwise: 逆时针排序

Stata
1
gr pie, over(occ7) noclockwise

angle0(0):指定第一块饼从0度开始,也就是三点钟方向

Stata
1
gr pie, over(occ7) angle0(0)

sort:按照份额的由小到大排序

Stata
1
gr pie, over(occ7) sort

Stata
1
gr pie, over(occ7) sort descending

Stata
1
gr pie, over(occ7) sort(occ7alpha)

改变饼的外观

Stata
1
gr pie, over(occ7) pie(3, explode)

Stata
1
gr pie, over(occ7) pie(3, explode(vlarge) color(cyan))

Stata
1
gr pie, over(occ7) pie(3, explode(vlarge) color(cyan)) pie(1, explode(small) color(gold))

Stata
1
gr pie, over(occ7) line(lc(sienna) lw(thick))

饼盘标签

Stata
1
gr pie, over(occ7) plabel(_all sum, size(small))

Stata
1
gr pie, over(occ7) plabel(_all name, size(small))

Stata
1
gr pie, over(occ7) plabel(_all percent, size(small) format("%2.0f") gap(-5))

Stata
1
gr pie, over(occ7) plabel(1 "Prof = 14.11%", size(small) color(black))

Stata
1
gr pie, over(occ7) plabel(_all name, gap(-5) size(small)) plabel(1 "32%", gap(5) size(small)) leg(off)

添加文字

Stata
1
gr pie, over(occ7) ptext(0 30 "This is some text")

Stata
1
gr pie, over(occ7) ptext(-10 00 "This is some text")

Stata
1
gr pie, over(occ7) ptext(-10 0 "This is some text", orientation(rvertical) placement(S))

控制图例

Stata
1
gr pie, over(occ7) leg(colfirst order(7 6 5 1 2 3 4) holes(1) pos(6) c(2))

分组绘图

Stata
1
gr pie, over(occ7) by(urban3, leg(at(4) pos(5)))

pieplot:更方便的绘制分类数据的饼图

Stata
1
2
3
4
5
sysuse auto, clear
pieplot rep78 foreign, sum plabelsubopts(size(*2)) ///
pie(1, color(red*2)) pie(2, color(red)) ///
pie(3, color(red*0.7)) pie(4, color(red*0.5)) ///
pie(5, color(red*0.3)) leg(row(1))

Stata
1
2
3
sysuse auto, clear
pieplot rep78
gre pieplot1

Stata
1
pieplot rep78 foreign

Stata
1
pieplot rep78 foreign, sum

Stata
1
pieplot rep78 foreign, sum plabelsubopts(size(*2))

Stata
1
pieplot rep78 foreign, sum plabelsubopts(size(*2)) pie(1, color(red*2)) pie(2, color(red)) pie(3, color(red*0.7)) pie(4, color(red*0.5)) pie(5, color(red*0.3)) legend(row(1))

# Stata

评论

程振兴

程振兴 @czxa.top
截止今天,我已经在本博客上写了659.4k个字了!

Your browser is out-of-date!

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

×