6

Hopefully, this is a stupid question, and easy to fix. When I run this simple gnuplot script:

#!/usr/bin/env gnuplot

set term png
set out "out.png"

plot "<jot -r -p 2 500 1 2" not w p pt 7 ps 4 lc rgb "#908DB6CD"

set term post eps enhanced color
set out "out.eps"

replot

exit

The png file looks like this:

png output

And the eps looks like this:

eps output

The pdfcairo terminal also gives me transparency. Any clues on how to make the eps files show transparency?

Many thanks in advance!

Vinicius Placco
  • 1,683
  • 2
  • 14
  • 24
  • 2
    The eps terminal doesn't support transparency. If you punch in `help term [termname]` and it doesn't have a transparency option then that terminal doesn't support transparency – Gavin Portwood Jun 08 '16 at 18:06
  • "help pdfcairo" doesn't say it has a transparency option. Does it really work? – Karl Jun 08 '16 at 18:52
  • Thanks @gavin-portwood, that is what I thought. @karl, yes, I could generate a pdf with pdfcairo with transparency. The workaround is then generate pdfs in gnuplot then do `pdftops -eps out.pdf` to get the eps. – Vinicius Placco Jun 08 '16 at 20:37

1 Answers1

4

I think I should respond to my own question, so at least this becomes a case closed.

After some more digging, and from the comments I received, the bottom line is that the gnuplot postscript terminal does not handle transparency, while the pdf and pdfcairo terminals do.

The trick is to generate an .eps file from a .pdf using pdftops:

#!/bin/bash

gnuplot << GNU

set term pdf
set out "out.pdf"

plot "<jot -r -p 2 500 1 2" not w p pt 7 ps 4 lc rgb "#908DB6CD"

GNU

pdftops -eps out.pdf

All of my .eps files are generated to be incorporated to LaTeX documents. Then, I could just switch to PDFLaTeX and be over with it. However, at times I like to edit the .eps to tweak the bounding box and other things by hand or using awk/sed. Anyway, hope this is helpful.

Vinicius Placco
  • 1,683
  • 2
  • 14
  • 24
  • 1
    You should be aware that the resulting EPS will not really have true transparency as in PostScript, there is no such thing. It's pretty likely that parts with transparency are actually rastered, i.e. you might loose the resolution independent vector qualities and end up with a (partial) bitmap. – Thomas W Jun 23 '16 at 17:55
  • You're right. I noticed that the resolution degraded a bit, but for the things I needed so far, it was not a big deal breaker (yet!). Thanks! – Vinicius Placco Jun 23 '16 at 18:32