假设待分析的变量为price
1.直方图的绘制
(1)默认纵坐标为density:
histogram price
(2)纵坐标为frequency:
hist price, ferquency
(3)纵坐标为fraction:
hist price, fraction
(4)纵坐标为percentage:
hist price, perecnt
(5)如何改变直方图每个小矩形的宽度(如何画出指定区间的直方图)
例如画出有5个区间的直方图:hist price, frequency bin(5)
(6)如何为直方图加上密度曲线
hist price, frequency normal
或者
hist price, frequency kdensity
(7)如何分组绘制直方图
例如根据国别绘制汽车价格的直方图:
hist price, frequency by (foreign)
2.箱线图的绘制
(1)如何绘制竖着的箱线图
graph box price
(2)如何绘制横着的箱线图
graph hbox price
(3)如何分组绘制箱线图
graph box price, over (foreign)
3.小提琴图的绘制
安装: ssc install vioplot
绘制:
vioplot price
分组绘制:
vioplot price, over(foreign)
PS:小提琴图的优势在于能够展示各个百分位