Graph 如何在gnuplot中创建自定义填充样式?

Graph 如何在gnuplot中创建自定义填充样式?,graph,gnuplot,Graph,Gnuplot,基本上,我希望在gnuplot中再现下图中的填充样式: 我尝试使用填充曲线的公共模式,但没有一种模式与图片中的模式相似。有没有办法在gnuplot中获得这种类型的图案(注意填充区域是而不是实体)? 谢谢。检查帮助填充曲线,并根据方案0xAARRGGBB将颜色设置为透明 代码: ### semitransparent fill between curves reset session # create some random test data set print $Data1 do

基本上,我希望在gnuplot中再现下图中的填充样式:

我尝试使用填充曲线的公共模式,但没有一种模式与图片中的模式相似。有没有办法在gnuplot中获得这种类型的图案(注意填充区域是而不是实体)?
谢谢。

检查
帮助填充曲线
,并根据方案
0xAARRGGBB
将颜色设置为透明

代码:

### semitransparent fill between curves
reset session

# create some random test data
set print $Data1
    do for [x=1:100] { print sprintf("%g %g %g %g",x,5*cos(x/7.)+rand(0),rand(0)+0.3,rand(0)+0.3) }
set print
set print $Data2
    do for [x=1:100] { print sprintf("%g %g %g %g",x,3*sin(x/9.)+rand(0),rand(0)+0.3,rand(0)+0.3) }
set print
unset key

plot $Data1 u 1:2 w l lc "red", \
     ''    u 1:($2-$3):($2+$4) w filledcurve lc rgb 0xeeff0000, \
     $Data2 u 1:2 w l lc "blue", \
     ''    u 1:($2-$3):($2+$4) w filledcurve lc rgb 0xee0000ff
### end of code
### special "fill" with dashed vertical lines
reset session

# create some random test data
set table $Data1
    set samples 1000
    plot [1:100] '+' u (x):(3*cos(x/5.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
set table $Data2
    set samples 1000
    plot [1:100] '+' u (x):(5*sin(x/7.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
set table $Data3
    set samples 1000
    plot [1:100] '+' u (x):(7*sin(x/9.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
unset table

unset key
plot $Data1 u 1:2 w l lc "red", \
     ''    u 1:($2-$3):(0):(1) w vectors lc rgb 0xddff0000 dt 1 nohead, \
     $Data2 u 1:2 w l lc "green", \
     ''    u 1:($2-$3):(0):($4+$3) w vectors lc rgb 0xdd00ff00 dt 2 nohead, \
     $Data3 u 1:2 w l lc "blue", \
     ''    u 1:($2-$3):(0):($4+$3) w vectors lc rgb 0xdd0000ff dt 3 nohead 
### end of code
结果:

### semitransparent fill between curves
reset session

# create some random test data
set print $Data1
    do for [x=1:100] { print sprintf("%g %g %g %g",x,5*cos(x/7.)+rand(0),rand(0)+0.3,rand(0)+0.3) }
set print
set print $Data2
    do for [x=1:100] { print sprintf("%g %g %g %g",x,3*sin(x/9.)+rand(0),rand(0)+0.3,rand(0)+0.3) }
set print
unset key

plot $Data1 u 1:2 w l lc "red", \
     ''    u 1:($2-$3):($2+$4) w filledcurve lc rgb 0xeeff0000, \
     $Data2 u 1:2 w l lc "blue", \
     ''    u 1:($2-$3):($2+$4) w filledcurve lc rgb 0xee0000ff
### end of code
### special "fill" with dashed vertical lines
reset session

# create some random test data
set table $Data1
    set samples 1000
    plot [1:100] '+' u (x):(3*cos(x/5.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
set table $Data2
    set samples 1000
    plot [1:100] '+' u (x):(5*sin(x/7.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
set table $Data3
    set samples 1000
    plot [1:100] '+' u (x):(7*sin(x/9.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
unset table

unset key
plot $Data1 u 1:2 w l lc "red", \
     ''    u 1:($2-$3):(0):(1) w vectors lc rgb 0xddff0000 dt 1 nohead, \
     $Data2 u 1:2 w l lc "green", \
     ''    u 1:($2-$3):(0):($4+$3) w vectors lc rgb 0xdd00ff00 dt 2 nohead, \
     $Data3 u 1:2 w l lc "blue", \
     ''    u 1:($2-$3):(0):($4+$3) w vectors lc rgb 0xdd0000ff dt 3 nohead 
### end of code

添加内容:(垂直虚线“填充”的解决方法)

老实说,(就像你的例子一样)如果你必须放大到非常近的地方才能看到半透明填充和垂直线填充之间的区别,那么我不确定这是否真的有必要

无论如何,这里有一个解决办法,可以“填充”垂直虚线。这是通过向量和虚线来实现的。
dt1
(=实线)、
dt2
(=虚线)、
dt3
(=虚线)。然而,这不是一个真正的填充,但需要足够的常规(此处:1000)数据点来提供这种印象。它还取决于线条颜色的透明度和图形的大小。但是,如果没有足够的常规数据点,可以对数据进行重新采样,这在gnuplot中并不简单(请参见:)

这看起来仍然与您的示例不同,但更接近

代码:

### semitransparent fill between curves
reset session

# create some random test data
set print $Data1
    do for [x=1:100] { print sprintf("%g %g %g %g",x,5*cos(x/7.)+rand(0),rand(0)+0.3,rand(0)+0.3) }
set print
set print $Data2
    do for [x=1:100] { print sprintf("%g %g %g %g",x,3*sin(x/9.)+rand(0),rand(0)+0.3,rand(0)+0.3) }
set print
unset key

plot $Data1 u 1:2 w l lc "red", \
     ''    u 1:($2-$3):($2+$4) w filledcurve lc rgb 0xeeff0000, \
     $Data2 u 1:2 w l lc "blue", \
     ''    u 1:($2-$3):($2+$4) w filledcurve lc rgb 0xee0000ff
### end of code
### special "fill" with dashed vertical lines
reset session

# create some random test data
set table $Data1
    set samples 1000
    plot [1:100] '+' u (x):(3*cos(x/5.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
set table $Data2
    set samples 1000
    plot [1:100] '+' u (x):(5*sin(x/7.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
set table $Data3
    set samples 1000
    plot [1:100] '+' u (x):(7*sin(x/9.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
unset table

unset key
plot $Data1 u 1:2 w l lc "red", \
     ''    u 1:($2-$3):(0):(1) w vectors lc rgb 0xddff0000 dt 1 nohead, \
     $Data2 u 1:2 w l lc "green", \
     ''    u 1:($2-$3):(0):($4+$3) w vectors lc rgb 0xdd00ff00 dt 2 nohead, \
     $Data3 u 1:2 w l lc "blue", \
     ''    u 1:($2-$3):(0):($4+$3) w vectors lc rgb 0xdd0000ff dt 3 nohead 
### end of code
结果:

### semitransparent fill between curves
reset session

# create some random test data
set print $Data1
    do for [x=1:100] { print sprintf("%g %g %g %g",x,5*cos(x/7.)+rand(0),rand(0)+0.3,rand(0)+0.3) }
set print
set print $Data2
    do for [x=1:100] { print sprintf("%g %g %g %g",x,3*sin(x/9.)+rand(0),rand(0)+0.3,rand(0)+0.3) }
set print
unset key

plot $Data1 u 1:2 w l lc "red", \
     ''    u 1:($2-$3):($2+$4) w filledcurve lc rgb 0xeeff0000, \
     $Data2 u 1:2 w l lc "blue", \
     ''    u 1:($2-$3):($2+$4) w filledcurve lc rgb 0xee0000ff
### end of code
### special "fill" with dashed vertical lines
reset session

# create some random test data
set table $Data1
    set samples 1000
    plot [1:100] '+' u (x):(3*cos(x/5.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
set table $Data2
    set samples 1000
    plot [1:100] '+' u (x):(5*sin(x/7.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
set table $Data3
    set samples 1000
    plot [1:100] '+' u (x):(7*sin(x/9.)):(rand(0)*0.5+0.3):(rand(0)*0.5+0.3) w table
unset table

unset key
plot $Data1 u 1:2 w l lc "red", \
     ''    u 1:($2-$3):(0):(1) w vectors lc rgb 0xddff0000 dt 1 nohead, \
     $Data2 u 1:2 w l lc "green", \
     ''    u 1:($2-$3):(0):($4+$3) w vectors lc rgb 0xdd00ff00 dt 2 nohead, \
     $Data3 u 1:2 w l lc "blue", \
     ''    u 1:($2-$3):(0):($4+$3) w vectors lc rgb 0xdd0000ff dt 3 nohead 
### end of code

放大以显示虚线:


您能发布您的数据和代码吗?到目前为止你试过什么?我猜这在gnuplot中可能相当困难。gnuplot的填充图案数量有限(请参阅)。据我所知,垂直线和虚线不在gnuplot曲目中。一个麻烦的解决方案可以稍微扩展一下,请看这里:谢谢你的回答,但我想创建图中的填充模式,而不是简单的实体模式。然后请提供一些数据和清晰的描述或草图,理想情况下是你的gnuplot代码“不起作用”!否则,这将是乏味的帮助!好的,现在我明白了。如果放大图像,“填充颜色”由细小的线条组成。请在问题中提及如此重要的细节!StackOverflow不是一个提问的平台,比如:“我想要这个!我该怎么做?”参见