如何在 Gnuplot 中为平面的 x<0 区域着色?
How to color the x<0 region of the plane in Gnuplot?
我正在尝试为二维绘图的 x<0 区域着色,即为下图的 II 和 III 区域着色
我试过使用
set style fill transparent solid 0.5 noborder
[-100:0] x<0 fs solid 1.0 lc rgb "grey" notitle
但它不起作用,只是给出一条直线而不是给整个半平面上色。有什么想法吗?
您可以在绘图后面放置一个矩形。检查以下内容:
但是,尽管我指定了 set style fill solid 1.0 noborder
。
,但我还没有找到为什么矩形有边框的原因
编辑:
我仍然不明白为什么 gnuplot 仍然绘制边框。但是我可以在定义完全透明的边框时摆脱边框,例如0xff123456
.
set obj 1 rect from graph 0,0 to first 0, graph 1 fc rgb 0xccff0000 behind
set obj 1 fs solid 1.0 border rgb 0xff123456
代码:
### half plot with colored background
reset session
set size ratio 1
set border 0
set xrange [-5:5]
set yrange [-5:5]
set xtics 1 axis
set ytics 1 axis
set xti
set grid x,y
set label 1 "I" at graph 0.75, graph 0.75 font ",20"
set label 2 "II" at graph 0.25, graph 0.75 font ",20"
set label 3 "III" at graph 0.25, graph 0.25 font ",20"
set label 4 "IV" at graph 0.75, graph 0.25 font ",20"
set obj 1 rect from graph 0,0 to first 0, graph 1 fc rgb 0xccff0000 behind
set obj 1 fs solid 1.0 border rgb 0xff123456
set xzeroaxis ls -1
set yzeroaxis ls -1
plot sin(x)
### end of code
结果:
我正在尝试为二维绘图的 x<0 区域着色,即为下图的 II 和 III 区域着色
我试过使用
set style fill transparent solid 0.5 noborder
[-100:0] x<0 fs solid 1.0 lc rgb "grey" notitle
但它不起作用,只是给出一条直线而不是给整个半平面上色。有什么想法吗?
您可以在绘图后面放置一个矩形。检查以下内容:
但是,尽管我指定了 set style fill solid 1.0 noborder
。
编辑:
我仍然不明白为什么 gnuplot 仍然绘制边框。但是我可以在定义完全透明的边框时摆脱边框,例如0xff123456
.
set obj 1 rect from graph 0,0 to first 0, graph 1 fc rgb 0xccff0000 behind
set obj 1 fs solid 1.0 border rgb 0xff123456
代码:
### half plot with colored background
reset session
set size ratio 1
set border 0
set xrange [-5:5]
set yrange [-5:5]
set xtics 1 axis
set ytics 1 axis
set xti
set grid x,y
set label 1 "I" at graph 0.75, graph 0.75 font ",20"
set label 2 "II" at graph 0.25, graph 0.75 font ",20"
set label 3 "III" at graph 0.25, graph 0.25 font ",20"
set label 4 "IV" at graph 0.75, graph 0.25 font ",20"
set obj 1 rect from graph 0,0 to first 0, graph 1 fc rgb 0xccff0000 behind
set obj 1 fs solid 1.0 border rgb 0xff123456
set xzeroaxis ls -1
set yzeroaxis ls -1
plot sin(x)
### end of code
结果: