2016-10-22 61 views
0

我正在对图像数据的直方图进行一些实验。在第一步中,我尝试制作一个线性矢量,其值为0到255.当打印这个矢量的直方图时,我假定每个值都具有相同的频率。但hist函数返回直方图,其中0具有较高的频率,255具有比其他值低的值。即使在选择不同的垃圾桶尺寸时...线性数据的直方图

我在做什么错?

rampImageData<-rep(rep(0:255, each=4), each=512) 
hist(rampImageData) 

enter image description here

+0

尽量简化您的代码行。然后仔细阅读“帮助(打破)”,你会发现如何理解你做错了什么。 – user31264

回答

1

它与 “分级”。

看:

library(ggplot2) 

“意外” 的统一行为:

qplot(rampImageData, geom = 'histogram') # default bins = 30 

enter image description here

“预期” 的统一行为:

qplot(rampImageData, geom = 'histogram', bins = 1) 

enter image description here

+0

谢谢,这解释了它! –