gpt4 book ai didi

gnuplot - 需要在 gnuplot 中绘制每第 n 行

转载 作者:行者123 更新时间:2023-12-02 10:25:07 26 4
gpt4 key购买 nike

我正在使用 gnuplot 并且有一些具有超过 2 个参数的数据。我不想使用 3D 图表。因此,我将在同一图中将数据分成几行。

在一种情况下,我的数据如下所示:

    #k   #N   #time   
1 1 0.000556134
2 1 0.00099
4 1 0.00201011
8 1 0.00376214
16 1 0.00675843
1 2 0.000717646
2 2 0.000794106
4 2 0.0016033
8 2 0.0033602
16 2 0.00795338
1 4 0.000476448
... ... ...

第一个是我使用的流的数量,第二个是缓冲区大小,最后一个是此操作使用的时间。

我想要一张图表,其中缓冲区大小为 X,时间为 Y,并且每个“使用的流数量”都有一行。到目前为止我的代码:

     reset
set autoscale # scale axes automatically
unset log # remove any log-scaling
unset label # remove any previous labels
set xtic auto # set xtics automatically
set ytic auto # set ytics automatically
#set logscale x 2
#set logscale y 2
set rmargin 10
set bmargin 5
set tmargin 5
set key left top
set title
set term png giant size 1500, 800 crop

set title "Adapter Stream Input" font "verdana, 20"
set xlabel "Buffer Size" font "verdana, 20"
set ylabel "Time in Seconds" font "verdana, 20"

set key right bottom spacing 4 width 5 height 5 font "verdana, 15"

set output "AdapterStreamInputTests.png"

plot "AdapterStreamInputTests.txt" using ($1 == 1 ? $2 : 1/0):($1 == 1 ? $3 : 1/0) title '1 Stream' with linespoints ls 1 linecolor rgb "blue", \
"AdapterStreamInputTests.txt" using ($1 == 2 ? $2 : 1/0):($1 == 2 ? $3 : 1/0) title '2 Stream' with linespoints ls 1 linecolor rgb "red", \
"AdapterStreamInputTests.txt" using ($1 == 4 ? $2 : 1/0):($1 == 4 ? $3 : 1/0) title '4 Stream' with linespoints ls 1 linecolor rgb "yellow", \
"AdapterStreamInputTests.txt" using ($1 == 8 ? $2 : 1/0):($1 == 8 ? $3 : 1/0) title '8 Stream' with linespoints ls 1 linecolor rgb "brown", \
"AdapterStreamInputTests.txt" using ($1 == 16 ? $2 : 1/0):($1 == 16 ? $3 : 1/0) title '16 Stream' with linespoints ls 1 linecolor rgb "pink"

set output

我现在的主要问题是它绘制的所有内容都是正确的,但它不会在图之间画线。我从 manual 读到在命令“使用”章节下:

It should be noted that plot 'le', plot 'le' using 1:2, and plot 'le' using ($1):($2) can be subtly dierent: 1) if le has some lines with one column and some with two, the rst will invent x values when they are missing, the second will quietly ignore the lines with one column, and the third will store an undened value for lines with one point (so that in a plot with lines, no line joins points across the bad point); 2) if a line contains text at the rst column, the rst will abort the plot on an error, but the second and third should quietly skip the garbage.

我认为我属于第三类,并且没有线条,因为每个图之间都有 4 个无效图,但我找不到任何方法来修复它。

我找不到一种方法让它忽略无效的图。我似乎找不到任何可以删除未使用的绘图的预处理方法。但我可能错过了一些东西。

最佳答案

那么,您有两种选择。

1.) 使用 every 命令,如图 here , alternative link (wayback machine)

2.) 使用缺少的参数,如上所述,您可以使用 ?: 符号在前面添加一个字符。关于伟大的更多详细信息再次inofficial FAQ , alternative link (wayback machine)

关于gnuplot - 需要在 gnuplot 中绘制每第 n 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9555389/

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