Gnuplot:“互补”虚线

时间:2019-05-06 09:41:25

标签: gnuplot

我想绘制“互补”虚线。我的意思是:我有3条曲线,它们在x值的特定范围内相同,但在此范围之外不同。当然,如果我仅在彼此之间绘制实线,我只会看到最上面的一条(在它们相同的范围内)。因此,我想将它们绘制为虚线:

1st line: dash-space-space-dash-space-space...

2nd line: space-dash-space-space-dash-space...

3rd line: space-space-dash-space-space-dash...

将它们绘制在上面应该会产生一条实线,并带有交替的颜色(三种线型)。 实现此目的最明显的方法是使用新的破折号,例如:

plot x dt "-  ",x dt " - ",x dt "  -"

但是,前导空白将被忽略。另外,诸如(20,20)之类的定义也不起作用,因为值的顺序始终为“实心长度,空白空间长度”。如果有一种方法可以反转此顺序,则可以轻松解决该问题。

(顺便说一下,在只有两条曲线的情况下,解决方案很简单:将第一个绘制为实线,第二个绘制为虚线。)

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

您可能正在寻找这样的东西:

### different shifted dashed lines
reset session

plot x, \
    0 w l lw 3 lc rgb "red" dt (20,40) notitle, \
    0 w l lw 3 lc rgb "web-green" dt (0,20,20,20) notitle, \
    0 w l lw 3 lc rgb "blue" dt (0,40,20,0) notitle

### end of code

enter image description here

添加:

使用以下代码,结果在wxt,qt,postscript,pngcairo(不能测试x11)中应该是相同的(或者说类似)。好吧,短划线长度因终端而异(请参见https://stackoverflow.com/a/55628295/7295599

### different shifted dashed lines
reset session
# set term wxt
# set term qt
set term pngcairo
set output "DashedLines.png"
# set term postscript color
# set output "DashedLines.eps"

plot x, \
    0 w l lw 3 lc rgb "blue" dt 1 notitle, \
    0 w l lw 3 lc rgb "web-green" dt (40,20) notitle, \
    0 w l lw 3 lc rgb "red" dt (20,40) notitle
set output
### end of code
相关问题