You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

gnuplot技术疑问:背景图为何会影响数据点的绘制位置?

gnuplot添加背景图后数据点位置偏移问题

我发现使用gnuplot绘图时,有无背景图会导致数据点的绘制位置不同,具体说明如下:

无背景图生成One.png的脚本

$DATA<<EOD
1.0000,"2.0 Years
10.0",277.5000,249.1100
2.0000,"3.0 Years
11.0",345.4167,312.1800
3.0000,"4.0 Years
12.0",413.3333,375.2500
4.0000,"5.0 Years
13.0",481.2500,438.3200
5.0000,"6.0 Years
14.0",549.1667,501.3900
6.0000,"7.0 Years
15.0",617.0833,564.4600
7.0000,"8.0 Years
16.0",685.0000,627.5300
8.0000,"9.0 Years
17.0",752.9167,690.6000
9.0000,"10.0 Years
18.0",820.8333,753.6700
10.0000,"11.0 Years
19.0",888.7500,816.7400
11.0000,"12.0 Years
20.0",956.6667,879.8100
12.0000,"13.0 Years
21.0",1024.5833,942.8800
13.0000,"14.0 Years
22.0",1092.5000,1005.9500
14.0000,"15.0 Years
23.0",1160.4167,1069.0200
15.0000,"16.0 Years
33.0",1228.3333,1699.7200
16.0000,"17.0 Years
34.0",1296.2500,1762.7900
17.0000,"18.0 Years
35.0",1364.1667,1825.8600
18.0000,"19.0 Years
36.0",1432.0833,1888.9300
19.0000,"20.0 Years
37.0",1500.0000,1952.0000
EOD
set datafile separator comma
set style data point
set terminal pngcairo enhanced size 1700,2200
set output 'C:\temp\One.png'
unset xtics; unset ytics; unset x2tics; unset y2tics
set grid noxtics
set grid noytics
set border 0
set colorsequence classic
set key off
set xrange [0:1699]
set yrange [0:2199]
set label 01 "This is the name" at 1136.00,2050.00 font "Tahoma,20" left front textcolor rgb "black"
set label 02 "Record No." at 1409.90,2007.00 font "Tahoma,20" left front textcolor rgb "black"
plot $DATA using ($3):($4) with points pt 1 ps 4 lc rgb "0xE25822" lw 3 notitle

生成的图表显示正常:
无背景图

使用One.png作为背景图生成Two.png的脚本

$DATA<<EOD
1.0000,"2.0 Years
10.0",277.5000,249.1100
2.0000,"3.0 Years
11.0",345.4167,312.1800
3.0000,"4.0 Years
12.0",413.3333,375.2500
4.0000,"5.0 Years
13.0",481.2500,438.3200
5.0000,"6.0 Years
14.0",549.1667,501.3900
6.0000,"7.0 Years
15.0",617.0833,564.4600
7.0000,"8.0 Years
16.0",685.0000,627.5300
8.0000,"9.0 Years
17.0",752.9167,690.6000
9.0000,"10.0 Years
18.0",820.8333,753.6700
10.0000,"11.0 Years
19.0",888.7500,816.7400
11.0000,"12.0 Years
20.0",956.6667,879.8100
12.0000,"13.0 Years
21.0",1024.5833,942.8800
13.0000,"14.0 Years
22.0",1092.5000,1005.9500
14.0000,"15.0 Years
23.0",1160.4167,1069.0200
15.0000,"16.0 Years
33.0",1228.3333,1699.7200
16.0000,"17.0 Years
34.0",1296.2500,1762.7900
17.0000,"18.0 Years
35.0",1364.1667,1825.8600
18.0000,"19.0 Years
36.0",1432.0833,1888.9300
19.0000,"20.0 Years
37.0",1500.0000,1952.0000
EOD
set datafile separator comma
set style data point
set terminal pngcairo enhanced size 1700,2200
set output 'C:\temp\Two.png'
unset xtics; unset ytics; unset x2tics; unset y2tics
set grid noxtics
set grid noytics
set border 0
set colorsequence classic
set key off
set xrange [0:1699]
set yrange [0:2199]
set label 01 "This is the name" at 1136.00,2050.00 font "Tahoma,20" left front textcolor rgb "black"
set label 02 "Record No." at 1409.90,2007.00 font "Tahoma,20" left front textcolor rgb "black"
plot 'C:\temp\One.png' binary filetype=PNG w rgbimage,\
$DATA using ($3):($4) with points pt 1 ps 4 lc rgb "0xE25822" lw 3 notitle

生成的Two.png中数据点被拉向图像中心,位置与One.png不一致:
带背景图

请问为何背景图会影响数据点的绘制位置?该如何避免此问题?

感谢您的解答,Roberto


内容的提问来源于stack exchange,提问作者Marionette_66

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 15:27:03