用GNUPlot制作直方图

用GNUPlot制作直方图,gnuplot,histogram,Gnuplot,Histogram,我想用1,2和1,3列从一个数据文件中制作两个比较直方图 (数据文件名为“Cumulos por Edades.tab”) 我一直能理解一些事情,但这不是我想要的。这是代码 (很抱歉,我无法上载结果的图像) 我想得到的是一个直方图,我可以看到两列,但我能得到的只是一列叠加在另一列上 如果你们能帮我一把,我将不胜感激。使用设置样式数据直方图等同于使用和直方图。您可以使用框覆盖此内容 最简单的方法是绘制为直方图。下面是一个最小的运行脚本: set style data histogram set s

我想用1,2和1,3列从一个数据文件中制作两个比较直方图

(数据文件名为“Cumulos por Edades.tab”)

我一直能理解一些事情,但这不是我想要的。这是代码

(很抱歉,我无法上载结果的图像)

我想得到的是一个直方图,我可以看到两列,但我能得到的只是一列叠加在另一列上


如果你们能帮我一把,我将不胜感激。

使用
设置样式数据直方图
等同于使用
和直方图
。您可以使用框覆盖此内容

最简单的方法是绘制为
直方图
。下面是一个最小的运行脚本:

set style data histogram
set style histogram cluster gap 1
plot "Cumulos por Edades.tab" u 2, "" u 3
这显示了直方图的绘制方式:第一行中的值以
x=0
为中心,第二行以
x=1
为中心,依此类推。不幸的是,您不能像在任何其他打印样式中一样使用第一列作为数值
x
-value。但您可以使用
xtic(1)
使用“原样”值,它将第一列的值读取为字符串,并将其用作tic标签:

set style data histogram
set style histogram cluster gap 1
plot "Cumulos por Edades.tab" u 2:xtic(1), "" u 3
第二个选项是使用
打印样式:

plot "Cumulos por Edades.tab" u 1:2 with boxes, "" u 1:3 with boxes
在这里,两列围绕相同的
x
-值绘制,尽管重叠。因此,需要将一列向左移动一点,将另一列向右移动一点。您必须设置固定的boxwidth:

set boxwidth 0.2 absolute
plot "Cumulos por Edades.tab" u ($1-0.1):2 with boxes,\
     "" u ($1+0.1):3 with boxes
plot "Cumulos por Edades.tab" u 1:2 with boxes, "" u 1:3 with boxes
set boxwidth 0.2 absolute
plot "Cumulos por Edades.tab" u ($1-0.1):2 with boxes,\
     "" u ($1+0.1):3 with boxes