#1168 postscript doesn't recognize transparent pattern

2D plot (258)
Matthew Gilson

in `help transparent`, it lists postscript as being able to handle transparent patterns, however, the following script (with attached datafile) don't produce the desired transparency in the patterned blocks. I'm not sure if the bug is in gnuplot, or in the documentation of this feature ...

(reproduced in gnuplot 4.4.2 and gnuplot 4.6.0 on OS-X 10.5).



## png terminal works
#set term png enhanced
#set output "test.png"

#postscript doesn't
set term post portrait color enhanced
set output 'test.ps'

n=20 #number of intervals
max=1.0 #max value
min=0.0 #min value
width=(max-min)/n #interval width

set boxwidth width*0.9
set xrange [0:1]

plot \ "test.dat" u (hist($1,width)):(1.0) smooth freq w boxes lc rgb "black" lt 1 lw 0.5 notitle fs solid 0.5, \ "test.dat" u (hist($2,width)):(1.0) smooth freq w boxes notitle fs transparent pattern 4 noborder lc rgb "blue" lt 1 lw 0.5


  • Matthew Gilson
    Matthew Gilson

    datafile for testing.

  • Matthew Gilson
    Matthew Gilson

    The above code also works in `pdf` and `pdfcairo` terminals for what it's worth ...

  • Ethan Merritt
    Ethan Merritt

    Thank you for the bug report.

    The full explanation is a bit complicated, but here goes.

    The postscript terminal does support transparent pattern fill in the general case. You can confirm this by running the demo "transparent.dem". However, the command "with boxes" does not trigger the general case treatment, but instead uses a simplified routine that only draws filled rectangles. It would be possible to make this simplified routine also handle transparent fill, but that would require a change to gnuplot itself, so let's defer that option for the moment.

    Fortunately, you can customize the output from the postscript terminal by editing either the individual output files or the shared configuration files on your machine. If you look near the top of the file "test.ps" created by your script, you will see a set of lines:
    % The following true/false flags may be edited by hand if desired.
    % The unit line width and grayscale image gamma correction may also be changed.
    /Color true def
    /Blacktext false def
    /Solid true def
    /Dashlength 1 def
    /Landscape false def
    /Level1 false def
    /Rounded false def
    /ClipToBoundingBox false def
    /SuppressPDFMark false def
    /TransparentPatterns false def

    Change that last one to read "true" rather than "false".

    One more change is needed. This can also be done in the specific output file but I recommend making the change in the system-wide configuration file, whose name is something like /usr/share/gnuplot/4.6/PostScript/prologue.ps
    Note the version number in the path name. The gnuplot executable will look for a directory matching its own version.

    The following change to the prologue file will cause the rectangles created by "with boxes" to honor the TransparentPatterns toggle. I will attach this as a patch file also.

    --- old/prologue.ps 2010-08-26 11:06:53.000000000 -0700
    +++ new/prologue.ps 2012-09-12 12:34:21.000000000 -0700
    @@ -266,7 +266,8 @@
    /PatternFill {gsave /PFa [ 9 2 roll ] def
    PFa 0 get PFa 2 get 2 div add PFa 1 get PFa 3 get 2 div add translate
    PFa 2 get -2 div PFa 3 get -2 div PFa 2 get PFa 3 get Rec
    - gsave 1 setgray fill grestore clip
    + TransparentPatterns {} {gsave 1 setgray fill grestore} ifelse
    + clip
    currentlinewidth 0.5 mul setlinewidth
    /PFs PFa 2 get dup mul PFa 3 get dup mul add sqrt def
    0 0 M PFa 5 get rotate PFs -2 div dup translate

    Once you modify this system-wide configuration file, the modified version will be included in every postscript output file you create using gnuplot. The state of transparent pattern fill can now be changed in these individual output files using the true/false toggle at the head of the file.

    The modification to prologue.ps will probably be included in version 4.6.1, to be released very soon. There may or may not be time to work out a modification to the core code so that "with boxes' triggers the transparent fill automatically without requiring you to edit the corresponding true/false toggle in the output file.

  • Matthew Gilson
    Matthew Gilson

    Thank you very much for the detailed workaround. Keep up the great work, and I'll keep posting bug reports when I find them (now that I've figured out how).

  • Ethan Merritt
    Ethan Merritt

    • status: open --> pending
  • Ethan Merritt
    Ethan Merritt

    • status: pending --> closed-fixed
    • milestone: --> 5.0