如何通过 R 中的 x 值缩放直方图上的 y 轴?
我有一些代表颗粒大小的数据。我想将每个分箱大小的粒子的频率绘制为直方图,但缩放频率但缩放粒子的大小(因此它代表该大小的总质量。)
我可以很好地绘制直方图,但我不确定如何按每个 bin 的 X 值缩放 Y 轴。
例如,如果我在 40-60 bin 中有 10 个粒子,我希望 Y 轴值为 10*50=500。
I have some data which represents a sizes of particles. I want to plot the frequency of each binned-size of particles as a histogram, but scale the frequency but the size of the particle (so it represents total mass at that size.)
I can plot a histogram fine, but I am unsure how to scale the Y-axis by the X-value of each bin.
e.g. if I have 10 particles in the 40-60 bin, I want the Y-axis value to be 10*50=500.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您最好使用条形图,以便通过箱的面积来表示总质量(即高度给出计数,宽度给出质量):
如果您的颗粒大小都不同,您应该首先将范围划分为适当数量的间隔为了创建part.type因子:
如果感兴趣的数量只是总质量。然后,适当的图是点图。与大量尺寸的条形图相比,它也更加清晰:
用箱代表总质量会产生误导,因为箱的面积没有意义。
You would better use barplot in order to represent the total mass by the area of the bins (i.e. height gives the count, width gives the mass):
If your particle sizes are all different, you should first cut the range into appropriate number of intervals in order to create part.type factor:
If the quantity of interest is only total mass. Then, the appropriate plot is the dotchart. It is also much clearer comparing to the bar plot for a large number of sizes:
Representing the total mass with bins would be misleading because the area of the bins is meaningless.
如果您确实想使用每个 bin 的中点作为缩放因子:
相反,如果您想使用每个样本点的实际值作为缩放因子:
if you really want to use the mid point of each bin as a scaling factor:
instead, if you want to use the actual value of each sample point as a scaling factor:
只需隐藏轴并根据需要重新绘制它们即可。
Just hide the axes and replot them as needed.