Gnuplot:绘制矩形时使用 "graph 0" 和 "graph 1"

Gnuplot: Use of "graph 0" and "graph 1" when drawing rectangles

我很高兴能对“​​图 0”和“图 1”的使用有所启发:

目标是将矩形绘制成图形,但是在绘制整个背景时,水平条纹不起作用,当我尝试使用图形0和图形1来指示左右边界时。

我正在关注 http://gnuplot.sourceforge.net/demo/rectangle.html

中的第二个示例
reset session
set xrange [0:6]
set yrange [0:25]

set obj 1 rect from graph 0,graph 0 to graph 1,graph 1 fc "red"   # paint the background

set obj 2 rect from graph 0,5 to graph 1,12 fc "green"            # produces nothing

set obj 3 rect from 'graph 0', 3 to 'graph 1',10 fc "blue"        # produces nothing 

set obj 4 rect from 'graph 0', 4 to 6,8 fc "yellow"               # this works. '...' and 6 required 

plot 'data02.txt'

我错过了什么?

我的 gnuplot 是 Ubuntu 20.04.4 LTS

上的 5.2.8

感谢您的帮助!

你为什么写'graph 0' 而不是 graph 0? 并检查 help coordinates:

If the coordinate system for x is not specified, first is used. If the system for y is not specified, the one used for x is adopted.

因此,例如graph 0, 5graph 0, 12 将在图表之外。如果你指的是 x- 和 y-coordinates,你应该写 graph 0, first 5graph 0, first 120,50,12。实际上,在您的情况下 graph 0first 0 相同。所以,这取决于你想要什么。

检查以下脚本。

脚本:

### coordinate sytems graph and first
reset session

set xrange [0:6]
set yrange [0:25]

set obj 1 rect from graph 0,       0 to graph 1,        1 fc "red"
set obj 2 rect from graph 0, first 5 to graph 1, first 12 fc "green"
set obj 3 rect from graph 0, first 3 to graph 1, first 10 fc "blue"
set obj 4 rect from graph 0, first 4 to       6,        8 fc "yellow"

plot NaN notitle   # or plot some data
### end of script

结果: