如何创建具有不同bin宽度的直方图 [英] How to create a histogram with varying bin widths

查看:104
本文介绍了如何创建具有不同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:

      这篇关于如何创建具有不同bin宽度的直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆