I want to recreate a plot I originally did in Matlab. It is an opaque surface with additionally plotted lines including markers.

The matlab picture I want to recreate with a concealed and unconcealed marker:

Some of these markers are "below" and some "above" the surface from the viewpoint. I also want this difference to be visible in Latex, but I dont know how. I tried with different layers "clip mode=individual", but then all points were concealed.

The surface in latex:

The surface in latex with clip mode = individual:

I know it is a slight different data set than in Matlab, but with view={0}{0}, I can verify that some points should be above and some below the surface aswell.

Hopefully my question is understandable and would be thankful, if someone could help.

I tried with the following code:

\begin{axis}[height = 10cm,
            width = 0.8\textwidth,
            axis x line*=bottom,
            axis y line*=left,
   clip mode=individual,
  \addplot3+[]table[x=y1, y=x, z=z1 ]{data/TsurfLines.txt};
  \addlegendentry{Row 1}
  \addplot3+[]table[x=y2, y=x, z=z2 ]{data/TsurfLines.txt};
  \addlegendentry{Row 2}
  \addplot3+[]table[x=y3, y=x, z=z3 ]{data/TsurfLines.txt};
  \addlegendentry{Row 3}
  \addplot3+[]table[x=y4, y=x, z=z4 ]{data/TsurfLines.txt};
  \addlegendentry{Row 4}
  \addplot3+[]table[x=y5, y=x, z=z5 ]{data/TsurfLines.txt};
  \addlegendentry{Row 5}
  \addplot3[surf,shader=interp,opacity=0.7] file {data/Tsurf.txt};
  • 1
    Please make a compilable minimal working example. We neither know what packages etc. you use nor can we reproduce your image because we don't have access to the data. Commented Dec 13, 2022 at 10:26
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – dexteritas
    Commented Dec 13, 2022 at 10:53
  • A tip: You can use backticks ` to mark your inline code.
    – dexteritas
    Commented Dec 13, 2022 at 10:54

1 Answer 1


PGFPlots does not have a z buffer extending outside of the individual plots, so what you want can not be done without manual work. You can pick the points yourself or if you have a threshold number or formula, you can use a filter like this:

\documentclass[tikz, border=1cm]{standalone}
xmin=0, xmax=1,
ymin=0, ymax=1,
zmin=0, zmax=1,
clip mode=individual,
only marks, domain=0.01:1, samples=10, samples y=1, 
z filter/.expression={0.2+0.1*sin(1000*y)<0.2?z:nan},
] (0.5,x,{0.2+0.1*sin(1000*x)});
\addplot3[surf, shader=interp, opacity=0.8, domain=0.01:1, samples=100, samples y=2] (x,y,{(x-1)^2-0.01/x});
only marks, domain=0.01:1, samples=10, samples y=1, 
z filter/.expression={0.2+0.1*sin(1000*y)>0.2?z:nan},
] (0.5,x,{0.2+0.1*sin(1000*x)});

Transparent surface plots with points below and above

  • Thanks for the explanation and the solution. I am sorry I havent provided a minimum working example yet- I was just working on it! But I think this answer helps me already
    – Kero
    Commented Dec 13, 2022 at 11:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .