统计图形-点图

点图水平轴表示定量变量的刻度,数据集中每次测量的数值用位于水平轴上的点表示,当数据重复时,点就放在另个点之上,在各数值位置形成一个柱。


下面用美国环保署(EPA)的测试数据为例作点图,测试数据表示100个行车里程等级,即每加仑燃料所能行驶的英里数,数据集逗号分隔如下所示。

36.3,41,36.9,37.1,44.9,36.8,30,37.2,42.1,36.7,32.7,37.3,41.2,36.6,32.9,36.5,33.2,37.4,37.5,33.6,40.5,36.5,37.6,33.9,40.2,36.4,37.7,37.7,40,34.2,36.2,37.9,36,37.9,35.9,38.2,38.3,35.7,35.6,35.1,38.5,39,35.5,34.8,38.6,39.4,35.3,34.4,38.8,39.7,36.3,36.8,32.5,36.4,40.5,36.6,36.1,38.2,38.4,39.3,41,31.8,37.3,33.1,37,37.6,37,38.7,39,35.8,37,37.2,40.7,37.4,37.1,37.8,35.9,35.6,36.7,34.5,37.1,40.3,36.7,37,33.9,40.1,38,35.2,34.8,39.5,39.9,36.9,32.9,33.8,39.8,34,36.8,35,38.1,36.9


先使用R的ggplot2库绘制点图,代码如下。

> library(xlsx)
Loading required package: rJava
Loading required package: xlsxjars
> library(ggplot2)
> d<-read.xlsx(file='E:\\AlgorithmResearch\\Statistics\\DataCD\\EXCEL\\EPAGAS.XLS',sheetName='Sheet1')
> p<-ggplot(d,aes(MPG)) + geom_dotplot() + ylab(label='Points Count') + xlab(label='MPG')
> p
stat_bindot: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
> ggsave(filename='E:\\AlgorithmResearch\\Statistics\\mpg.png')
Saving 5.57 x 5.56 in image
stat_bindot: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
> 
统计图形-点图_第1张图片

使用相同的数据集在Minitab中的效果。


图的表现力都是一样的,默认风格却大相径庭。

你可能感兴趣的:(统计图形-点图)