如何在Gnuplot中使用标签和颜色绘制点?
我想在Gnuplot中用单独的标签和颜色绘制点 我有一个数据文件如何在Gnuplot中使用标签和颜色绘制点?,gnuplot,Gnuplot,我想在Gnuplot中用单独的标签和颜色绘制点 我有一个数据文件a.dat: ###label x y z 1 244.8 18 6.1 2 248.0 10.4 7 3 294.4 6.3 13.7 4 248.0 7.5 8.92 5 240.0 3.69 6.61 6 240.48 3.69 8.92 7 256 5.7 15.8 8 256 7 10.6 9 256 4.1 8.2 10 256 5.1 12.3 以下命令可以工作 splot
a.dat
:
###label x y z
1 244.8 18 6.1
2 248.0 10.4 7
3 294.4 6.3 13.7
4 248.0 7.5 8.92
5 240.0 3.69 6.61
6 240.48 3.69 8.92
7 256 5.7 15.8
8 256 7 10.6
9 256 4.1 8.2
10 256 5.1 12.3
以下命令可以工作
splot 'a.dat' using 2:3:4:1 with labels
set palette model RGB defined (0 'black',1 'blue', 2 'green', 3 'red')
splot 'a.dat' using 2:3:4:($1==3?1:$1==6?2:$1==9?3:0) with points palette
但是我怎样才能混合它们呢?假设我正确理解了你的问题,如果你只想在几个特定点上设置几个特定的颜色,你真的需要调色板吗? 您将使用两种打印样式
和点
以及和标签
。您可以在一个打印命令中组合它们
代码:
### variable color points
reset session
$Data <<EOD
###label x y z
1 244.8 18 6.1
2 248.0 10.4 7
3 294.4 6.3 13.7
4 248.0 7.5 8.92
5 240.0 3.69 6.61
6 240.48 3.69 8.92
7 256 5.7 15.8
8 256 7 10.6
9 256 4.1 8.2
10 256 5.1 12.3
EOD
myColor(col) = column(col)==3 ? 0x0000ff : \
column(col)==6 ? 0x00ff00 : \
column(col)==9 ? 0xff0000 : 0
set key noautotitle
splot $Data u 2:3:4:(myColor(1)) w p pt 7 lc rgb var, \
'' u 2:3:4:1 w labels offset 0.0,0.7,0.7
### end of code
好吧,你必须决定:
- 仅使用标签可能很难定位数据点的确切位置
- 使用没有偏移的点和标签可能很难读取数字
假设我正确理解了你的问题,如果你只想在几个特定点上设置几个特定的颜色,你真的需要调色板吗? 您将使用两种打印样式
和点
以及和标签
。您可以在一个打印命令中组合它们
代码:
### variable color points
reset session
$Data <<EOD
###label x y z
1 244.8 18 6.1
2 248.0 10.4 7
3 294.4 6.3 13.7
4 248.0 7.5 8.92
5 240.0 3.69 6.61
6 240.48 3.69 8.92
7 256 5.7 15.8
8 256 7 10.6
9 256 4.1 8.2
10 256 5.1 12.3
EOD
myColor(col) = column(col)==3 ? 0x0000ff : \
column(col)==6 ? 0x00ff00 : \
column(col)==9 ? 0xff0000 : 0
set key noautotitle
splot $Data u 2:3:4:(myColor(1)) w p pt 7 lc rgb var, \
'' u 2:3:4:1 w labels offset 0.0,0.7,0.7
### end of code
好吧,你必须决定:
- 仅使用标签可能很难定位数据点的确切位置
- 使用没有偏移的点和标签可能很难读取数字
@IV_uu好的,那么你想要彩色标签而不是彩色点?@IV_u好的,那么你想要彩色标签而不是彩色点?