1

我正在尝试使用 R 制作向量的直方图。当我绘制它时,x 轴从 5 变为 9,但直方图的一部分在 5 之前(最低数字是 4.414002),一部分在 9 之后。我的 y 轴也是如此,它从 0 到 5000,但最高的“五线谱”略高于这个 5000。

为什么它不是从向量中的最低值开始?请注意,只是条形不够长,图表大小合适(因此 mar 或 oma 设置没有问题,我尝试更改这些设置,但没有帮助)

下面是我的代码

import rpy2.robjects as R
import R_functions as R_funct


csvData = (R.r['read.csv'](file='/homes/ndeklein/test.csv', head=True, sep='\t'))

hist = R.r.hist
R.r.png('/homes/ndeklein/test_intensity_hist.png', width=300, height=300)
intensityVector = csvData[0]
logIntensityVector = R.r['log10'](intensityVector)

hist(logIntensityVector, main='Intensity per feature histogram', xlab='logged intensity', ylab='frequencies of features', br=20)

R.r['dev.off']()

编辑:

我发现了问题所在,在 R 代码中它看起来像这样:

vector = c(5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 5.67750749154535, 6.7399637450174, 6.7399637450174, 6.7399637450174, 6.7399637450174, 6.7399637450174, 6.7399637450174, 6.7399637450174, 6.7399637450174)
hist(vector, breaks=20)

但是因为范围在 4-9 之间(嗯,在这个例子中更少),所以有 20 次休息太多了。将休息时间设置为 6 可以解决问题。

4

1 回答 1

0

将中断放在较低的数字上(在我的示例中为 br = 6)

hist(logIntensityVector, main='Intensity per feature histogram', xlab='logged intensity', ylab='frequencies of features', br=6)

解决了这个问题。

于 2012-02-22T17:12:43.643 回答