1

I am using gnuplottex in Overleaf to write a document using the IEEETran document style. When I plot filledcurves the result kind of bad as it seems not to be in a vector graphics format; thus getting pixelated upon zooming into the figure. Additionaly, some weird white boxes are floating around hideing parts of a label.

I developed the figure locally on my machine using the cairopdf terminal and Gnuplot 5.4. The first picture show the resulting pdf of of Latex using the cairolatex terminal. The second picture shows a very deep zoom in the test pdf done with the cairopdf terminal where everything looks good.

set style fill transparent solid 0.35 noborder
plot for[i=1:num_states] normal(x, word(means, i), word(std, i)) notitle with filledcurves y1=0

What is going on? I read that epslatex has some trouble with transparency is that here also the case?

Bad figure from latex with buggs Test figure done with cairopdf

Simon T.
  • 49
  • 8

1 Answers1

2

The PostScript language itself (including *.eps) does not support transparency or alpha-channel colors. So no *.ps or *.eps file can portray transparent/translucent areas properly. At best it can be approximated by using some intermediate representation that does handle alpha channels and then translating the final resulting blended colors to PostScript, but that means later color balance adjustments made during viewing or printing will not preserve the correct balance in the blended areas.

There should be no problem with pdf. I don't know what caused that partial white rectangle. Maybe if you show a more complete script that created the figure?

Edited:

Using set terminal cairolatex pdf in gnuplot should solve the pixelation and transparency issues. You can create a new question if the unwanted white rectangles persist.

Ethan
  • 13,715
  • 2
  • 12
  • 21
  • Hi Ethan, I did some further reading and found this post (https://stackoverflow.com/questions/29321707/can-transparency-be-used-with-postscript-eps). Here the exact mechanism is explained with the rastarization fallback for non-opaque objects. They mention a resolution parameter for the fallback. Is it possible to set it through gnuplottex? Naive question. Is there a technical reason why we dont have a terminal that outputs a pdf for the graph and tex file for the text directly (no eps detour)? – Simon T. May 01 '22 at 11:05
  • Who is "we"? Gnuplot has `set term cairolatex pdf`. You can also use `set term tikz` and produce a pdf file for separate inclusion rather than using it to produce embedded tikz commands. – Ethan May 01 '22 at 16:38
  • The `pdf` option for `cairolatex` is the best. It is exactly what I was looking for. To me it seems like this is the solution to most of the transparency problems people having with latex and gnuplot. If you add it as an answer I would be happy to accept it. – Simon T. May 01 '22 at 19:28