Date 如何使用gnuplot绘制彩色点
如何使用gnuplot绘制隔离点(非连接点): x轴必须是日期的第一列, y轴是第二列 第三列必须是点的颜色(颜色定义为范围(例如:从1到3红色, 从4到6绿色…)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
一些解决办法可以是:
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变量
的作用,我在答案的开头提到了这一点。我将这部分扩展为完整的脚本,请参见编辑后的答案。