如何创建具有不同bin宽度的直方图
使用其他历史记录,我与其他人失败. 一个简单的问题是使用以下数据:
I have been unsuccessful with other using hist plot. A simple problem would be using the following data:
age range - frequency - central band width - bin width - height (respectively)
1-4 - 30 - 2.5 - 3 - 10
5-6 - 20 - 5.5 - 1 - 20
7-17 - 30 - 12 - 10 - 3
随着年龄的增长,X轴上的年龄呈线性比例,因此1-4的箱宽为3,高度为10,5-6的箱宽为1,高度为20,7-17为10,高度为3.
With age along the X axis, with a linear scale, so the bin width for 1-4 would be 3, with height 10, bin width for 5-6 would be 1 with height of 20, and 7-17 would be 10 and the height would be 3.
如何将这些数据放入Word/记事本文档.dat
文件中?
然后如何使用它们在gnuplot
中设置直方图?
How would can I place these data into a Word/notepad document .dat
file?
And how can I then use them to set up a histogram in gnuplot
?
我将使用以下数据文件格式(仅使用空格分隔字段):
I would use the following data file format (use only white spaces to delimit fields):
"age range" "frequency" "central band width" "bin width" "height"
1-4 30 2.5 3 10
5-6 20 5.5 1 20
7-17 30 12 10 3
- 要使用可变的框宽进行绘图,请使用
boxes
绘图样式.这样一来,您就可以将一列中的值用作宽度. - 在
xtic(1)
中,您将第一列中的条目用作xticlabel. - To plot with variable boxwidth, use the
boxes
plotting style. That allows you to use the value from a column as width. - With
xtic(1)
you use the entry in the first column as xticlabel.
因此,一个相当简单的绘图脚本如下所示:
So a rather simple plotting script looks as follows:
set style fill solid noborder
set yrange [0:*]
set offset 1,1,1,0
plot 'file.txt' using 3:5:4:xtic(1) with boxes notitle
版本4.6.3和pngcairo终端的结果是:
The result with version 4.6.3 and the pngcairo terminal is: