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

Windows下gnuplot设置pointsize<1时误差棒点出现白背景求助

解决Gnuplot误差棒小点出现白背景的问题

问题根源

Windows平台下Gnuplot 5.4.x系列的wxt终端对尺寸小于1的点存在渲染bug,导致误差棒的点显示白色背景,无法正确应用设置的线条颜色。

可行解决方案

1. 更换终端类型

将wxt终端替换为qt终端,qt终端在小尺寸点的渲染上更稳定:

set term qt 0 enhanced  # 替代原有的set term wxt 0 enhanced

若需多窗口,可指定窗口编号,如set term qt 1 enhanced。

2. 隐藏误差棒的点(仅保留误差线)

如果不需要误差棒两端的点,直接使用yerrorbars替代errorbars,只绘制垂直误差线:

# 替换原误差棒绘图行
$data1 u ($0-width/2):($1-5):($3) w yerrorbars lc 8 notitle,\
$data1 u ($0+width/2):2:($4) w yerrorbars lc 8 notitle,\

彻底规避点的渲染问题,同时保留误差线功能。

3. 调整点类型与背景设置

若必须保留点,可使用实心点类型(如pt 5、pt 7),并禁用点背景色:

set pointbgcolor nobg  # 禁用点背景色
# 修改误差棒的pointtype
$data1 u ($0-width/2):($1-5):($3) w errorbars pt 7 ps 0.1 lc 8 notitle,\
$data1 u ($0+width/2):2:($4) w errorbars pt 7 ps 0.1 lc 8 notitle,\

注:部分旧版本Gnuplot不支持nobg,可改用set pointbgcolor bgnd匹配画布背景。

4. 升级Gnuplot版本

尝试升级到Gnuplot 5.5及以上开发版本,新版本可能修复了wxt终端的渲染bug。

修改后的完整示例代码

$data1 << EOD
#Plan_1 Plan2
#50.4/28    50.25
49.8523456  49.49061091 2.49261728  2.474530546 0.005
44.15166667 43.608  2.207583333 2.1804  <0.005
53.68666667 53.492  2.684333333 2.6746  0.005
52.57555556 52.263  2.628777778 2.61315 0.005
45.48722222 45.53   2.274361111 2.2765  0.005
52.87444444 52.539  2.643722222 2.62695 0.005
45.27277778 45.275  2.263638889 2.26375 0.005
50.98   50.384  2.549   2.5192  0.005
EOD 

set term qt 0 enhanced  # 更换为qt终端
set encoding utf8
set lmargin 10
set bmargin 5
set tics font 'Arial,16'
set xlabel 'DVH parameters' font 'Arial,16' offset 0,-1
set ylabel 'Dose (Gy)' font 'Arial,16' offset -2,0
width=0.3
set title 'PTV_{45}' font 'Arial,16'
set boxwidth width
set style data histogram
set style fill solid
set style histogram cluster gap 1
set xtic scale 0
set auto x
set key font 'Arial,16'
set yrange [30:75]
set xrange [-1:8]
set xtics ('D_{mean}' 0,'D_{min}' 1,'D_{max}' 2,'D_{5}' 3,'D_{95}' 4,'D_{2}' 5,'D_{98}' 6,'D_{50}' 7)
set bars 2
plot $data1 u ($0-width/2):1 w boxes lc 3 t '50.4/28',\
     $data1 u ($0+width/2):2 w boxes lc 7 t '50/25',\
     $data1 u ($0-width/2):($1-5):($3) w yerrorbars lc 8 notitle,\
     $data1 u ($0+width/2):2:($4) w yerrorbars lc 8 notitle,\
     $data1 u 0:($1+4):5 w labels rotate by 0 font "Times,10" notitle

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 17:55:15