Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
gnuplot:使用数据中的颜色填充曲线_Gnuplot - Fatal编程技术网

gnuplot:使用数据中的颜色填充曲线

gnuplot:使用数据中的颜色填充曲线,gnuplot,Gnuplot,我想用调色板填充曲线 我的数据如下所示: 0 0 0 1 1 1 1 0 0.5 2 2 2 3 3 3 3 2 0.6 我的绘图命令: set terminal pngcairo size 800,600 set output "test.png" set style fill solid 1.0 noborder unset border unset xtics unset ytics plot '< awk ''{print $1,$2,$9,"\n",$3,$4,$9,"\n",

我想用调色板填充曲线

我的数据如下所示:

0 0 0 1 1 1 1 0 0.5
2 2 2 3 3 3 3 2 0.6
我的绘图命令:

set terminal pngcairo size 800,600
set output "test.png"
set style fill solid 1.0 noborder
unset border
unset xtics
unset ytics
plot '< awk ''{print $1,$2,$9,"\n",$3,$4,$9,"\n",$5,$6,$9,"\n",$7,$8,$9,"\n",$1,$2,$9,"\n"}'' rect.txt' \
using 1:2:3 with filledcurves fillcolor palette notitle
产生以下结果:

填充曲线的打印样式不支持使用文件中的数据按调色板着色。这里的主要问题是,通常在使用
调色板
时,需要根据某些数据值更改单个区域内的颜色

要使用调色板分数位置的颜色值为单个矩形上色,可以使用
palete frac
。这需要迭代所有矩形

为了正确使用
填充曲线
,您需要不同的数据格式,如

x1 y1_low y1_high
x2 x2_low y2_high
由于您使用的是
awk
,因此您可以为实际打印提取更多信息:

set terminal pngcairo size 800,600
set output "test.png"
set style fill solid 1.0 noborder
unset border
unset xtics
unset ytics
file = 'rect.txt'
lines = system(sprintf('wc -l %s | cut -d'' '' -f 1', file))
frac(x) = system(sprintf('awk ''{if (NR==%d){ print $9 }}'' %s', x, file))
rect(x) = sprintf('awk ''{if (NR==%d){ print $1,$2,$4,"\n",$5,$8,$6,"\n"}}'' %s', x, file)
plot for [i=1:lines] '< '.rect(i) using 1:2:3 with filledcurves palette frac frac(i) notitle
你得到了输出


使用您的代码,我只绘制了两个正方形。。。如果我将行的最后一个值更改为10,5,0,则会得到
第11行:调色板分数超出范围。我还不知道正方形的颜色和数据中的最后一个值有什么关系。。。它的值是10的倍数吗?你确定我的数据文件用了三行吗?关键字
frac
为调色板中的特定部分提供颜色。这些值必须在
[0:1]
范围内。如果要提供绝对值,只需删除
frac
。可能您需要修复cbrange。我已经检查过多次了。我对我的问题进行了编辑,以向您展示我得到的结果。我只得到了两个正方形,而不是三个。嗯,我真的不能帮你调试,对我来说它很好用。你检查过个人电话是否正常吗?
打印行
(在gnuplot脚本/gnuplot终端内部)会给你什么?如果这不是
3
,shell上的
wc-l rect.txt
会给你什么?打印分形(1)
打印分形(2)
打印分形(3)
会返回你期望的吗?等等。
x1 y1_low y1_high
x2 x2_low y2_high
set terminal pngcairo size 800,600
set output "test.png"
set style fill solid 1.0 noborder
unset border
unset xtics
unset ytics
file = 'rect.txt'
lines = system(sprintf('wc -l %s | cut -d'' '' -f 1', file))
frac(x) = system(sprintf('awk ''{if (NR==%d){ print $9 }}'' %s', x, file))
rect(x) = sprintf('awk ''{if (NR==%d){ print $1,$2,$4,"\n",$5,$8,$6,"\n"}}'' %s', x, file)
plot for [i=1:lines] '< '.rect(i) using 1:2:3 with filledcurves palette frac frac(i) notitle
0 0 0 1 1 1 1 0 0.5
2 2 2 3 3 3 3 2 0.6
2 2 2 1 1 1 1 2 0.2