Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am very fond of latex labels in my gnuplot figures, and the way I generate most of them is via the pslatex terminal.

Here, I would like to take advantage of transparency in a figure (superimposed histograms), while keeping latex labels. My problem is that this is not achievable using pslatex, as postscript does not handle transparency.

Of course, I could use the svg terminal, generate the core of the figure with transparency, then generate only the axes using pslatex, then put everything together by hand in inkscape, and save in .pdf (but this is heavy, to say the least).

Do you know if there is any straightforward way to do this inside gnuplot?

Once again, thank you for you time!

PS: for the record, the pslatex procedure I follow has been exposed here: How to set what appears as a title in a document viewer menu bar?.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

If I recall correctly, postscript does not support transparency. That means you have to select a terminal that supports transparency (and TeX). In ConTeXt transparency works fine, in the text labels as well as transparent graphs (more information: ConTeXt wiki - Gnuplot). ConTeXt uses it's own terminal (based on the metapost terminal). You could give the metapost terminal a try.

This example is taken from the Gnuplot home page - demos and slightly modified; maybe there's something similar you can do in LaTeX.

\usemodule [gnuplot]

\definecolor [mytrans] [r=0.7,t=0.5,a=1]
\starttext

\startGNUPLOTscript [plt]
set clip two
set style fill  transparent solid 0.50 noborder
set key title "Gaussian Distribution"
set key inside left top vertical Left reverse enhanced autotitles nobox
set key noinvert samplen 1 spacing 1 width 0 height 0 
set style function filledcurves y1=0
set title "\\color[mytrans]{Transparent} filled curves" 
set xrange [ -5.00000 : 5.00000 ] noreverse nowriteback
set yrange [ 0.00000 : 1.00000 ] noreverse nowriteback
unset colorbox
Gauss(x,mu,sigma) = 1./(sigma*sqrt(2*pi)) * exp( -(x-mu)**2 / (2*sigma**2) )
d1(x) = Gauss(x, 0.5, 0.5)
d2(x) = Gauss(x,  2.,  1.)
d3(x) = Gauss(x, -1.,  2.)
GPFUN_Gauss = "Gauss(x,mu,sigma) = 1./(sigma*sqrt(2*pi)) * exp( -(x-mu)**2 / (2*sigma**2) )"
GPFUN_d1 = "d1(x) = Gauss(x, 0.5, 0.5)"
GPFUN_d2 = "d2(x) = Gauss(x,  2.,  1.)"
GPFUN_d3 = "d3(x) = Gauss(x, -1.,  2.)"
plot d1(x) fs solid 1.0 lc rgb "forest-green" title "µ = 0.5 $\\sigma$ = 0.5",\
d2(x) lc rgb "gold" title "µ =  2.0 $\\sigma$ = 1.0",\
d3(x) lc rgb "red" title "µ = -1.0 $\\sigma$ = 2.0"
\stopGNUPLOTscript

\useGNUPLOTgraphic [plt]

\stoptext

The result:

result

Tested with context 2011.05.18 18:04, gnuplot 4.7 patchlevel 0

share|improve this answer
    
First of all, thank you for your answer; I must say this looks great. However, I am using "debian testing" and therefore I have gnuplot 4.4 patchlevel 0, in which the ConTeXt terminal does not exist yet. If there are no other ways, I suppose I have to choose whether I prefer having such nice figures or not changing anything in my system at the moment. –  Alex Apr 4 '12 at 12:51
1  
@Alex You don't need 4.7 for the context terminal, 4.6 suffices, see gnuplot 4.6 release notes and that is already in unstable. One option would be to compile gnuplot (takes 5 minutes) with --prefix=/home/me/bin/gnuplot, add it to your PATH and remove it when 4.6 reaches testing. –  Marco Apr 4 '12 at 13:43
    
Thank you Marco, I had indeed checked this. But an update to the sid version of gnuplot also requires an update of libstdc++ for instance and, in turn, of many more packets. For personal deadline reasons, it is a bit risky for me to change so much at the moment, but your help is appreciated ;). I will do that in a few months. –  Alex Apr 4 '12 at 14:06

Transparency and latex labels are supported also by terminal cairolatex.

share|improve this answer
    
Thank you for pointing this out; it seems it also requires gnuplot 4.6. –  Alex Nov 26 '12 at 15:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.