Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/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
Date 如何使用gnuplot绘制彩色点_Date_Gnuplot - Fatal编程技术网

Date 如何使用gnuplot绘制彩色点

Date 如何使用gnuplot绘制彩色点,date,gnuplot,Date,Gnuplot,如何使用gnuplot绘制隔离点(非连接点): x轴必须是日期的第一列, y轴是第二列 第三列必须是点的颜色(颜色定义为范围(例如:从1到3红色, 从4到6绿色…) 一些解决办法可以是: plot for [i=0:5] 'cp.txt' using ( i==$3 ? $1 : 1/0 ):2 notitle with points linestyle i 一些解决办法可以是: plot for [i=0:5] 'cp.txt' using ( i==$3 ? $1 : 1/0 ):2 no

如何使用gnuplot绘制隔离点(非连接点): x轴必须是日期的第一列, y轴是第二列 第三列必须是点的颜色(颜色定义为范围(例如:从1到3红色, 从4到6绿色…)


一些解决办法可以是:

plot for [i=0:5] 'cp.txt' using ( i==$3 ? $1 : 1/0 ):2 notitle with points linestyle i

一些解决办法可以是:

plot for [i=0:5] 'cp.txt' using ( i==$3 ? $1 : 1/0 ):2 notitle with points linestyle i

有几种方法可以做到这一点:

您可以定义几种线型,然后使用
linecolor变量
,这允许您使用最后一列作为线型索引:

set timefmt '%Y-%m-%d'
set xdata time
set format x '%Y-%m'

set style increment user
set style line 1 lc rgb 'red'
set style line 2 lc rgb 'blue'
set style line 3 lc rgb 'green'
set style line 4 lc rgb 'magenta'
set style line 5 lc rgb 'yellow'

set style data points
plot 'data.txt' using 1:2:3 linecolor variable pt 7 ps 2 t ''
结果是:

这要求您定义尽可能多的线样式

或者,您可以定义相应的调色板,并使用
linecolor palete
对点进行着色:

set timefmt '%Y-%m-%d'
set xdata time
set format x '%Y-%m'

set cbrange [1:6]
set palette defined (1 'red', 3.5 'red', 3.5 'green', 6 'green')

set style data points
unset colorbox
plot 'data.txt' using 1:2:3 linecolor palette pt 7 ps 2 t ''
使用此选项时,您必须注意,
cbrange
与定义的
调色板所用的值相匹配(此处为
1
6
),因为调色板的值通常会根据颜色范围进行调整

上面的脚本给出了结果:


有几种方法可以做到这一点:

您可以定义几种线型,然后使用
linecolor变量
,这允许您使用最后一列作为线型索引:

set timefmt '%Y-%m-%d'
set xdata time
set format x '%Y-%m'

set style increment user
set style line 1 lc rgb 'red'
set style line 2 lc rgb 'blue'
set style line 3 lc rgb 'green'
set style line 4 lc rgb 'magenta'
set style line 5 lc rgb 'yellow'

set style data points
plot 'data.txt' using 1:2:3 linecolor variable pt 7 ps 2 t ''
结果是:

这要求您定义尽可能多的线样式

或者,您可以定义相应的调色板,并使用
linecolor palete
对点进行着色:

set timefmt '%Y-%m-%d'
set xdata time
set format x '%Y-%m'

set cbrange [1:6]
set palette defined (1 'red', 3.5 'red', 3.5 'green', 6 'green')

set style data points
unset colorbox
plot 'data.txt' using 1:2:3 linecolor palette pt 7 ps 2 t ''
使用此选项时,您必须注意,
cbrange
与定义的
调色板所用的值相匹配(此处为
1
6
),因为调色板的值通常会根据颜色范围进行调整

上面的脚本给出了结果:


可能重复的或可能重复的可能重复的或可能重复的感谢,这对我帮助很大!但是如果我想根据第三列值自动分配颜色,我应该写什么(忽略范围)例如:value 1=>red value 2=>blue value 3=>green等等!@zoma.saf这就是
linecolor variable
的作用,我在答案的开头提到了这一点。我将这部分扩展为完整的脚本,请参阅编辑后的答案。非常感谢,这对我帮助很大!但是如果我想根据第三列值(忽略范围idea plz)例如:值1=>红色值2=>蓝色值3=>绿色等等!@zoma.saf这就是
linecolor变量
的作用,我在答案的开头提到了这一点。我将这部分扩展为完整的脚本,请参见编辑后的答案。