gnuplot:在图像上以正确的比例和位置绘制图形。

4
我的问题是在图像上绘制一个图。这个图像不仅仅是作为一个漂亮的背景,还应该与图相对齐。
图是由许多彩色点表示汽车在坐标系中的速度和位置。这部分已经解决了。
现在我想将图与道路的图像对齐,但是遇到了问题。
数据文件的格式如下:
-60.2501 106.115 0 0
-68.1729 98.0388 0 0
[...]

这是我目前的进展:x-位置,y-位置,速度,忽略最后一个数字。
set multiplot

set yrange [-1280:1280]
set xrange [-1280:1280]
# set xrange [-1470:1280]

set size ratio 1
plot 'BL.jpg' binary filetype=jpg origin = (-1280,-1280) with rgbimage

set origin 0, 0
set size ratio 1

set yrange [-1280:1280]
set xrange [-1280:1280]
set key autotitle columnhead
set palette defined (0 "black", 0.25 "blue", 0.5 "red", 0.75 "yellow", 1 "green")
plot 'output.txt' using 1:2:3 with points palette pt 6 ps 0.1

unset multiplot

很遗憾,沿着x轴它没有对齐:

enter image description here

通过调整一些数字,我可以勉强对齐,但这只是随机猜测。
我尝试在 set multiplot 之后添加这个。
set lmargin at screen 0.1
set rmargin at screen 0.98
set tmargin at screen 0.98
set bmargin at screen 0.2

导致稍微更好的适合度,但现在比例不正确?

enter image description here

当使用右键选择一个矩形进行缩放时,道路图像也会消失吗?

这里是一个示例数据文件的链接:Here

轨道图像:Track image


对我来说,现在包含在问题中的这张图片看起来很好。速度信息和赛道对齐得很好。你指的是哪个比例尺?缩放的问题是“multiplot”模式的问题,只有最后一个绘图会在缩放时被重新绘制... - Christoph
1
抱歉,我的错。实际上它是对齐的。看来我已经看这些图表太久了,把自己搞糊涂了。多图问题能否以某种方式解决,也许可以通过以不同的方式编写脚本而避免使用多图吗?(还是我应该发布一个新问题?) - knorke
1个回答

2

您不需要使用multiplot,只需使用单个plot命令绘制两个文件(感谢提示:)):

reset
set size ratio 1
set autoscale fix
set key above autotitle columnhead
set palette defined (0 "black", 0.25 "blue", 0.5 "red", 0.75 "yellow", 1 "green")
plot 'BL.jpg' binary filetype=jpg center=(0,0) with rgbimage notitle,\
     'output.txt' using 1:2:3 with points palette pt 6 ps 0.1 title columnheader(1)

这将得到:

enter image description here

注意:

  • set autoscale fix 使用紧密的范围(对于 xycb),而不会扩展到下一个刻度。

  • 使用 center=(0,0) 可以消除对精确图像尺寸的最后一个明确依赖。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接