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

gnuplot如何缩放地图使其适配50k+量程的x/y坐标轴并铺满绘图区

问题原因

默认使用rgbimage绘制png图片时,gnuplot会直接将图片的像素坐标作为绘图的数据坐标,2000×2000的地图自然只会覆盖坐标轴(0,0)到(2000,2000)的范围,和你设置的0~57599的轴量程不匹配。

解决方案

在加载图片的binary参数中显式指定坐标映射规则,把图片的像素范围拉伸到和你的坐标轴范围完全对齐即可,无需调整数据相关的配置。

修改后的完整代码

reset

set dgrid3d 200,200 qnorm 2
set xrange [0:57599]
set yrange [0:57599]

set table $Data
  splot "data.dat" using 1:2:4 
unset table

# create contour lines
set contour base
set cntrparam level incremental 0, 5, 100
unset surface

set table $Contour
  splot "data.dat" using 1:2:4 
unset table
unset key
set palette defined ( 0 "#ff0000", 40 "#0000ff", 60 "#00ff00", 100 "#e0e0e0" )
set size square
set style fill transparent solid 0.4 noborder

# 仅修改了地图绘制的一行,添加origin、dx、dy参数完成坐标映射
plot    "Map.png" binary filetype=png origin=(0,0) dx=57599/2000 dy=57599/2000 w rgbimage, \
        $Data u 1:2:(6):(6):3 with boxxyerror palette, \
        $Contour u 1:2:3 w l lt rgb "grey"

通用适配写法(修改轴范围无需手动调整参数)

如果后续需要调整x/y轴的量程,可以用gnuplot内置的量程变量自动计算映射参数,替换地图绘制行即可:

"Map.png" binary filetype=png origin=(GPVAL_X_MIN,GPVAL_Y_MIN) dx=(GPVAL_X_MAX-GPVAL_X_MIN)/2000 dy=(GPVAL_Y_MAX-GPVAL_Y_MIN)/2000 w rgbimage,

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.17 06:15:03