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

如何解决gnuplot中立方体动画面不完全不透明的问题?

解决Gnuplot立方体面不完全不透明的问题

问题根源

你使用polygons样式绘制立方体面时,存在两个核心问题:

  • 默认填充未设置为完全实心,可能带有半透明效果
  • polygons不会自动处理3D场景的深度遮挡,导致后方的面会透过前方的面显示,视觉上像是半透明

可行解决方案

方案1:调整填充样式并启用3D遮挡

在代码开头添加填充设置和遮挡开关,确保面完全实心且正确遮挡:

unset border; unset tics; unset key; set view equal xyz
set style fill solid 1.0  # 设置100%实心不透明填充
set hidden3d              # 启用3D遮挡,隐藏被前方面遮挡的部分
set datafile separator comma
set term gif animate delay 5
set output 'cubos.gif'
do for [ang=1:360:2] {
    set view 60, ang
    splot 'cubos1.dat' with polygons fc "gold", \
          'cubos2.dat' with polygons fc "red", \
          'cubos3.dat' with polygons fc "blue", \
          'cubos4.dat' with polygons fc "black", \
          'cubos5.dat' with polygons fc "yellow", \
          'cubos6.dat' with polygons fc "green"
}
unset output

方案2:改用pm3d样式绘图(更推荐)

pm3d是Gnuplot专门用于3D填充面的样式,会自动处理深度排序和遮挡,效果更稳定:

unset border; unset tics; unset key; set view equal xyz
set pm3d depthorder solid 1.0 border linecolor "black"  # 启用深度排序、实心填充和黑色边框
set datafile separator comma
set term gif animate delay 5
set output 'cubos.gif'
do for [ang=1:360:2] {
    set view 60, ang
    splot 'cubos1.dat' with pm3d fc "gold", \
          'cubos2.dat' with pm3d fc "red", \
          'cubos3.dat' with pm3d fc "blue", \
          'cubos4.dat' with pm3d fc "black", \
          'cubos5.dat' with pm3d fc "yellow", \
          'cubos6.dat' with pm3d fc "green"
}
unset output

关键参数说明

  • solid 1.0:控制填充的不透明度,1.0代表完全不透明,取值范围为0(全透明)到1(完全不透明)
  • depthorder:仅针对pm3d,让Gnuplot自动根据3D空间位置排序面的绘制顺序,确保远处的面不会遮挡近处的面
  • hidden3d:针对polygons样式,强制隐藏被前方图形遮挡的部分

内容的提问来源于stack exchange,提问作者Luis Federico Berruezo Sánchez

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 01:05:17