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

Gnuplot 5.4.5无法渲染Y轴标签问题求助

问题:Gnuplot生成的图表缺失Y轴标签

我使用Gnuplot 5.4.5执行以下脚本:

set key enhanced font "Monospaced,13"
set grid

set style line 1 \
    linecolor rgb '#a82828' \
    linetype 1 linewidth 3 \
    pointtype 5 pointsize 1.0

set xlabel "Entropy"
set xrange [-0.05:1.05]
set ylabel "Amortized work"

set terminal png enhanced font "Monospaced,13" size 500,350
set output 'EntropyToAmortizedWork.png'

plot 'EntropyToAmortizedWork.dat' with linespoints linestyle 1 notitle

replot
exit

数据文件EntropyToAmortizedWork.dat为外部数据文件,执行后生成的图表出现Y轴标签缺失的排版异常:
缺失Y轴标签

请问该如何解决?


解决方案

核心原因

Gnuplot中,坐标轴标签的配置必须在指定终端(set terminal)之后才能生效。你的脚本先设置了set xlabel和set ylabel,之后才定义png终端,导致标签没有应用终端的字体、尺寸等参数,最终无法正常渲染显示。

修复后的脚本

将所有坐标轴标签的设置代码移到set terminal和set output之后即可,修改后的完整脚本如下:

set key enhanced font "Monospaced,13"
set grid

set style line 1 \
    linecolor rgb '#a82828' \
    linetype 1 linewidth 3 \
    pointtype 5 pointsize 1.0

set xrange [-0.05:1.05]

set terminal png enhanced font "Monospaced,13" size 500,350
set output 'EntropyToAmortizedWork.png'

# 坐标轴标签移至终端设置后
set xlabel "Entropy"
set ylabel "Amortized work"

plot 'EntropyToAmortizedWork.dat' with linespoints linestyle 1 notitle

exit

额外优化

  • 去掉冗余的replot命令,plot命令已完成绘图操作;
  • 若标签仍有截断风险,可通过offset参数调整位置,例如:set ylabel "Amortized work" offset -1,0。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 04:55:19