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

如何为自定义刻度标签设置不同颜色?遇未定义变量tc错误

解决gnuplot自定义刻度标签颜色报错"undefined variable: tc"的问题

你遇到的错误是因为所用的gnuplot版本不支持用tc作为textcolor的缩写,程序把tc识别成了未定义变量。只需要把代码里的tc rgb替换成全称textcolor rgb就能解决问题。

修改后的代码如下:

set ytics ("1" 1.0 textcolor rgb 'purple', "0.8" 0.8 textcolor rgb 'purple', "1" 1.4 textcolor rgb 'forest-green', "0.8" 1.2 textcolor rgb 'forest-green', "1" 1.8 textcolor rgb 'black', "0.8" 1.6 textcolor rgb 'black')

set y2tics ("1" 1.2 textcolor rgb 'blue', "0.8" 1.0 textcolor rgb 'blue', "1" 1.6 textcolor rgb 'red', "0.8" 1.4 textcolor rgb 'red', "1" 2.0 textcolor rgb 'brown', "0.8" 1.8 textcolor rgb 'brown')

如果你的gnuplot是5.0及以上的新版本,也可以保留tc缩写,但要确保语法格式正确——每个刻度项的属性参数紧跟数值。不过用全称textcolor能更好地兼容不同版本,避免类似报错。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 02:06:02