gpt4 book ai didi

gnuplot - Gnuplot 中非数值数据的 x 范围

转载 作者:行者123 更新时间:2023-12-04 22:48:35 27 4
gpt4 key购买 nike

运行以下脚本时,我收到一条错误消息:

set terminal postscript enhanced color
set output '| ps2pdf - histogram_categorie.pdf'
set auto x
set key off
set yrange [0:20]
set style fill solid border -1
set boxwidth 5
unset border
unset ytic
set xtics nomirror
plot "categorie.dat" using 1:2 ti col with boxes

我得到的错误信息是
smeik:plots nvcleemp$ gnuplot categorie.gnuplot 

plot "categorie.dat" using 1:2 ti col with boxes
^
"categorie.gnuplot", line 13: x range is invalid

文件内容 categorie.dat
categorie   aantal
poussin 13
pupil 9
miniem 15
cadet 15
junior 6
senior 5
veteraan 8

我知道问题是我没有定义 x 范围。我怎样才能让他使用第一列作为 x 范围的值?或者我是否需要将行号作为 x 范围并让他使用第一列作为标签?我正在使用 Gnuplot 4.4。

我最终试图获得一个与我之前制作的情节相同的情节。那个工作正常,但在 x 轴上有数字数据。
set terminal postscript enhanced color
set output '| ps2pdf - histogram_geboorte.pdf'
set auto x
set key off
set yrange [0:40]
set xrange [1935:2005]
set style fill solid border -1
set boxwidth 5
unset border
unset ytic
set xtics nomirror
plot "geboorte.dat" using 1:2 ti col with boxes,\
"geboorte.dat" using 1:($2+2):2 with labels

和文件内容 geboorte.dat
decennium aantal
1940 2
1950 1
1960 3
1970 2
1980 3
1990 29
2000 30

最佳答案

boxes style 期望 x 值是数字。这很简单,我们可以给它伪列 0,它本质上是脚本的行号:

plot "categorie.dat" using (column(0)):2 ti col with boxes

现在您可能希望以某种方式获得绘图第一列中的信息。我假设您希望这些字符串成为 x-tics:
plot "categorie.dat" using (column(0)):2:xtic(1) ti col with boxes

*小心,这可能不适用于您当前的 boxwidth设置。您可能需要考虑 set boxwidth 1plot ... with (5*column(0)):2:xtic(1) ... .

编辑 -- 以上面发布的数据文件为例,我已经测试了上述两个更改以使 boxwidth 正确,并且两者似乎都有效。

关于gnuplot - Gnuplot 中非数值数据的 x 范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13934163/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com