如何在颜色循环 gnuplot 脚本中设置虚线或虚线

问题描述 投票:0回答:1

我正在绘制两个 dat 文件,File1 和 File2,使用

set1Color(n) = n==0 ? 0x008000  : n==1 ? 0xFF0000 : n==2 ? 0x000000 : 0xFF8C00
set2Color(m) = m==0 ? 0x008000  : m==1 ? 0xFF0000 : m==2 ? 0x000000 : 0x00008B

plot 'File1' u 1:2:(set1Color(column(-2))) w l  lw 1.0 lc rgb   var notitle  ,  'File2' u 1:2:(set2Color(column(-2)))  w l   lw 1.0  lc rgb var notitle

我想要 File2 中的底部三行,在 (set2Color(colum(-2)) 下定义,为点线或虚线,并且应跳过一个替代的破折号/点。

gnuplot
1个回答
1
投票

我还是不确定我是否明白你想要什么。 我的猜测是您正在寻找定制的破折号样式? 检查

help dashtype
和下面的最小示例。

脚本:(适用于 gnuplot>=5.0.1,2015 年 6 月)

### custom dash pattern and color
reset session

# create some random test data
set table $Data
    plot for [i=1:7] '+' u 0:(i+rand(0))
unset table

myColors     = "0x008000 0xFF0000 0x000000 0xFF8C00"
myColor(col) = (n=column(col)+1, int(word(myColors, n>3 ? 4 : n)))

set dashtype 1 (5,5)
set dashtype 2 (12,12)
set key box opaque

plot $Data u 1: 2:    (myColor(-2)) w l lw 1.0 lc rgb var dt 1 title "Data1", \
        '' u 1:($2+8):(myColor(-2)) w l lw 1.0 lc rgb var dt 2 title "Data2 = shifted Data1"
### end of script

结果:

© www.soinside.com 2019 - 2024. All rights reserved.