gnuplot
我在使用(版本 6.0 补丁级别 1,Microsoft Windows 版本 10.0.19045.5737)生成绘图时遇到了一个奇怪的问题
。我需要将绘图中的colorbox
值反转,即颜色渐变应该从底部的高值到顶部的低值。
我注意到,当使用某些终端时,colorbox
显示完全空白或白色,没有预期的颜色渐变:
wxt
, 成功emf
, 成功pngcairo
, 成功svg
, 成功pdfcairo
, 失败epscairo
, 失败
我已附上示例图片:
pngcairo
终端输出
pdfcairo
终端输出
wxt
使用“将图导出到文件”选项从交互式窗口输出为 pdf 。
这是我正在使用的脚本的简化版本:
reset session
set encoding utf8
#set terminal wxt size 800,400 font "Arial,9"
#set terminal pngcairo size 800,400 font "Arial,9"
#set output "diagram.png"
set terminal pdfcairo size 10,5 in font "Arial,14"
set output "diagram.pdf"
set tics out nomirror
unset key
set style circle radius graph 0.01
set style fill transparent solid 1 border lc ls -1
set palette viridis maxcolors 25
set xrange [400:450]
set yrange [100:600]
set xlabel "Temperature/°C"
set ylabel "Index"
set cblabel "Depth (m)"
set cbtics offset -1,0
set multiplot layout 1,2
set title "normal colorbox"
plot "data.txt" u 2:3:1 w circle lc palette
set colorbox invert
set title "inverted colorbox"
replot
unset multiplot
unset output
看起来data.txt
是这样的:
Depth Temp Index
201.05 427.34 251.70
205.24 431.39 296.30
209.24 414.27 185.66
211.89 432.81 140.98
215.54 413.30 299.13
217.17 424.50 272.27
221.00 426.93 184.91
221.50 420.06 241.14
222.95 420.16 467.74
223.60 410.67 196.70
226.39 416.30 166.96
228.87 430.30 437.81
232.22 415.00 343.18
232.23 415.76 494.67
235.17 410.02 224.60
238.31 429.06 302.89
238.37 414.77 367.09
238.49 421.26 195.13
239.36 414.16 161.46
241.46 418.85 263.24
242.76 431.97 378.32
243.17 420.91 154.06
246.77 421.16 135.39
247.30 414.63 411.32
248.97 410.22 146.30
我的脚本/数据有问题或者这是一个错误?
我可以确认报告的问题,并将其追溯到提交 84e724843f(应用于 6.0-rc1 和 6.0-rc2 之间)。此错误应该只影响 qt 和 cairo 终端。修复方法很简单,但遗憾的是,在当前的 6.0 版本中我没有找到解决方法。
只是为了好玩,这里有一个针对 6.0.x 版本的解决方法,它也适用于
qt
和pdfcairo
终端,但是会失去自动缩放功能。您可以这样做:set palette negative
脚本:
结果:(来自 gnuplot 6.0.2 和 qt 终端)