3

I really would like to have a figure like this one:

enter image description here

But all I got is this one:

enter image description here

Why my opacity didn't work? Whit a file TEX with all the coordinates, do you know something that could plot in a good way these 2D functions over time?

Here is my TEX code.

\begin{document}

\begin{tikzpicture}

\pgfplotstableread{
plot1   plot2   plot3   plot4   plot5
0       0       0       0       0
0.348081    0.187042    0.0673327    0.0784015    0.0455678
0.165143    0    0.0664995    0.0685961    0.0375407
0.17641    0.0781801    0    0    0
0.183147    0.421627    0.471163    0.367463    0.268439
0.106028    0.145975     0.185666    0.240872    0.357571
0.0164603    0.107278    0.114965    0.130172    0.170262
0.00473057    0.0598978    0.0943741    0.114495    0.120619
0       0       0       0 0
}\dummydata
\begin{axis}[
samples=30,
domain=0:1,
samples y=0, ytick={1,...,5},
zmin=0,
 area plot/.style={
      fill opacity=0.2,
      draw=none,
      fill=blue!70,
      mark=none,
      smooth
     }
   ]
\pgfplotsinvokeforeach{5,4,3,...,1}{
   \addplot3 [area plot] table [x expr=\coordindex, y expr=#1, 
 z=plot#1]
       {\dummydata};
 }

\end{axis}
\end{tikzpicture}
\end{document}
  • Have you tried with fill opacity after fill=blue ? – marsupilam Apr 26 '17 at 23:01
  • 1
    Have you tried switching PDF viewers? Transparency in PDFs is a bit finicky sometimes, in my experience. Also, as a side note, if you ever want to print this and encounter problems, those might be down to the transparency as well (I'm not saying it will happen, but I recently made this experience and thought I'd mention it, since we're on the topic). Anyway, CampaIgnis's code from below works for me as well. – alpenwasser Apr 26 '17 at 23:32
  • Your code, as is (after adding the needed boilerplate, clearly... use a minimal working example (MWE) next time!), works for me when I view it with all the viewers I have (evince, okular, the embedded one in firefox). Which PDF viewer are you using? – Rmano Apr 27 '17 at 8:33
10

I am using TeXLive 2016, and I think I got exactly the opacity you wanted with your code:

\documentclass{memoir}

\usepackage{tikz,pgfplotstable}

\begin{document}
\begin{tikzpicture}

\pgfplotstableread{
plot1   plot2   plot3   plot4   plot5
0       0       0       0       0
0.348081    0.187042    0.0673327    0.0784015    0.0455678
0.165143    0    0.0664995    0.0685961    0.0375407
0.17641    0.0781801    0    0    0
0.183147    0.421627    0.471163    0.367463    0.268439
0.106028    0.145975     0.185666    0.240872    0.357571
0.0164603    0.107278    0.114965    0.130172    0.170262
0.00473057    0.0598978    0.0943741    0.114495    0.120619
0       0       0       0 0
}\dummydata

\begin{axis}[
    samples=30,
    domain=0:1,
    samples y=0, 
    ytick={1,...,5},
    zmin=0,
    area plot/.style={
        fill opacity=0.2,
        draw=none,
%       densely dashed, very thin,% I would consider this line or a similar line instad of draw=none
        fill=blue!70,
        mark=none,
        smooth
    }
]
\pgfplotsinvokeforeach{5,4,3,...,1}{
    \addplot3 [area plot] table [x expr=\coordindex, y expr=#1, z=plot#1]{\dummydata};
}

\end{axis}
\end{tikzpicture}
\end{document}

This works with pdfLaTeX and LuaLaTeX. Please consider adding a full MWE with \documentclass and all packages necessary, see What makes a good MWE?.

As alpenwasser noted, transparency might be a problem for some viewers, see https://en.wikipedia.org/wiki/Portable_Document_Format#Transparency.

The post Plotting several 2d functions in a 3d graph seems related.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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