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'm using pgfplots to plot two filled curves. I'd like them to overlap transparently so that the "lower" figure can be seen through the "upper one". Using the forget style mode will draw the first figure transparently, but that's the one that is below !

MWE:

\begin{tikzpicture}
  \begin{axis}[ybar,bar width=2pt]
  \addplot[color=red,mark=,draw=red,fill opacity=0.5] table[x=0,y=1]\transtable;
  \addplot[color=blue,mark=,draw=blue,fill opacity=0.5] table[x=2,y=3]\transtable;
  \end{axis}
\end{tikzpicture}

Is there a direct way to get somewhat transparent overlapping plots ?

share|improve this question
    
add fill opacity=0.5 to the addplot command and please include a simple MWE which in this case 6-7 lines long so easier than typing out the question :). –  percusse Dec 5 '12 at 0:34
    
The problem with what you recommend is that it doesn't appear to work for bar charts. –  Suresh Dec 5 '12 at 0:48
    
I think I figured out my problem. I need to use draw opacity instead of fill opacity. Not sure whether I should delete the question. Ideally @percusse can post an answer and I'll accept it, since that's what got me on the right track. –  Suresh Dec 5 '12 at 0:53
add comment

1 Answer 1

up vote 9 down vote accepted

You can use fill opacity key to change the ...hmm... fill opacity.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[enlargelimits=false]
  \addplot[red,no marks,fill] {x} \closedcycle;
  \addplot[no marks,fill,blue,fill opacity=0.2,samples=100] {10*sin(x*20*pi)} \closedcycle;
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
add comment

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.