gnuplot:误解数据(直方图) [英] gnuplot: misinterpreting data (histogram)

查看:31
本文介绍了gnuplot:误解数据(直方图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下示例数据文件,我想将其作为直方图绘制在gnuplot

I have following sample data file, which I want to plot in gnuplot as a histogram

1   1
2   2
4   3

我正在使用以下命令来绘制数据:plot "sample.data" with boxes,它会生成以下图表:

I am using following command to plot the data: plot "sample.data" with boxes, which produces following chart:

      ##
      ##
  ######
  ######
########
########

而图表应如下所示(3应该没有值):

whereas, the chart should look like this (there should be no value for 3):

      ##
      ##
  ##  ##
  ##  ##
####  ##
####  ##

help boxwidth中我了解:默认情况下,相邻的框的宽度会扩展到彼此接触为止".对我来说,这似乎是一个严重的错误/功能不足.我希望我的数据能够正确表示,而不要绘制不存在的数据.当这个简单的示例失败时,我如何信任gnuplot正确表示我的数据?

From help boxwidth I understand that: "By default, adjacent boxes are extended in width until they touch each other". This seems like a serious bug/misfeature to me. I want my data to be represented correctly, and not to plot nonexistent data. How can I trust gnuplot to represent my data correctly, when this simple example fails?

推荐答案

如果您还阅读了周围的其他句子,您会发现,只有在未指定任何明确的boxwidth的情况下,这些框才会自动计算.可以通过使用第三列或使用set boxwidth:

If you had read also the other sentences around it, you would have seen, that the boxes are calculated automatically only if no exlicit boxwidth was specified. This can be done either by using a third column, or by setting one width with set boxwidth:

set boxwidth 1
plot "sample.data" with boxes

plot "sample.data" using 1:2:(1) with boxes

请注意,boxwidth以x轴为单位.

Note, that the boxwidth is given in units of the x-axis.

这篇关于gnuplot:误解数据(直方图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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