pdfsvggnuplotpngcolorbox

Transparency and inverted colorbox produce inconsistent colors on gnuplot


I'm encountering a strange issue in gnuplot when combining transparency with an inverted colorbox.

The colors shown in the colorbox do not match the colors actually used in the plot. Additionally, in some cases, the colorbox appears fully opaque even though transparency is applied to the plot elements.

This inconsistent behavior seems to depend on both terminal used (wxt, pngcairo, pdfcairo, svg) and gnuplot version (I've tested with 5.4.10, 6.0.rc1, and 6.0.3).

The bug could be related to this other one.

In the special case of the svg terminal, the font used in the graph title is not rendered correctly.

I provided screenshots demonstrating how the output differs across terminals and versions.


Outputs on wxt terminal. Note the plot D. On pngcairo the output is the same.

output on wxt terminal gnuplot version 6.0.3

output on wxt terminal gnuplot version 6.0.rc1

output on wxt terminal gnuplot version 5.4.10


Outputs on pdfcairo terminal (as snapshot from Foxit PDF Reader). Compare the plots A, B and D.

output on pdfcairo terminal gnuplot version 6.0.3

output on pdfcairo terminal gnuplot version 6.0.rc1

output on pdfcairo terminal gnuplot version 5.4.10


Outputs on svg terminal (as exported from Inkscape). Note both the graph title (unbold and default font) and plots C and D.

output on svg terminal gnuplot version 6.0.3

[output on svg terminal gnuplot version 6.0.rc19

output on svg terminal gnuplot version 5.4.10


My script

reset session
set encoding utf8

#set terminal wxt size 800, 600 font "Arial,12"

#set terminal pngcairo size 800, 600 font "Arial,12"
#set output "png.png"

#set terminal svg size 800, 600 font "Arial,12"
#set output "svg.svg"

set terminal pdfcairo size 8, 6 in font "Arial,14"
set output "pdf.pdf"

$Data << EOD
2561.80   0.348   0.045
2563.60   0.403   0.221
2564.50   0.511   0.132
2565.40   0.491   0.521
2575.43   0.472   0.328
2576.60   0.467   0.570
2577.15   0.490   0.496
2579.80   0.543   0.487
2581.10   0.440   0.571
2583.40   0.510   0.597
2587.13   0.496   0.574
2588.80   0.581   0.568
2590.60   0.586   0.628
2594.20   0.576   0.485
2595.85   0.505   0.345
2596.70   0.395   0.191
2597.55   0.477   0.248
2598.55   0.426   0.151
2599.00   0.506   0.270
2600.35   0.471   0.316
2601.35   0.474   0.283
2603.65   0.474   0.249
2603.95   0.483   0.295
2605.75   0.484   0.263
2606.65   0.434   0.257
2609.00   0.476   0.314
2609.35   0.475   0.259
2610.25   0.486   0.233
2611.15   0.461   0.223
2612.05   0.462   0.131
2612.95   0.476   0.214
2619.00   0.583   0.259
EOD

unset key
set tics out nomirror
set style circle noclip radius graph 0.02

set palette defined (\
 1 "#440154",\
 3 "#21908d",\
 5 "#fde725")

set palette maxcolor 3

set multiplot layout 2,2 title sprintf("Version %g patchlevel %s", GPVAL_VERSION, GPVAL_PATCHLEVEL) font "Arial-Bold"
# ---------
set label 1 "A" at graph 0.1, graph 0.9 font "Arial-Bold,20"
set style fill solid 0.25 border lc ls -1
set title "circles with fill solid 0.25"
plot $Data u 2:3:1 w circles lc palette
# ---------
set label 1 "B"
unset style fill
set style fill transparent solid 0.25 border lc ls -1
set title "circles with fill transp. solid 0.25"
replot
# ---------
set label 1 "C"
set colorbox invert
unset style fill
set style fill solid 0.25 border lc ls -1
set title "circles with fill solid 0.25, colorbox invert"
replot
# ---------
set label 1 "D"
unset style fill
set style fill transparent solid 0.25 border lc ls -1
set title "circles with fill transp. solid 0.25, colorbox invert"
replot
# ---------
unset multiplot
unset output

Solution

  • There may be some bugs lurking there.

    But I have to say that it's not clear to me whether the colorbar would ideally show transparency or fillstyle at all. The plot command might contain multiple components with with distinct fill styles, all sharing the same palette. In each of your examples the entire plot uses the global fillstyle and one's first thought is that the colorbox ought to match that. But in other cases everything in the plot might use fillstyles other than the global default. Should the colorbox use the global fillstyle even though it doesn't match the plot? Or should it disregard the fillstyle altogether and just show the palette?

    As a separate matter, all of the plots A/B/C/D appear transparent in the SVG output, which they should not be.