TransWikia.com

Coaxial cable in pgfplots

TeX - LaTeX Asked on March 12, 2021

I want to draw a coaxial cable using pgfplots. It more or less has to be done within that program because in my document, I also want to add some 3D plot next to the cable. (I guess a solution using pure TikZ could also be used, but it has to use the pgfplots coordinates for the aforementioned reasion).

I use the below code with the result following it. You can more or less see the problem: The inner cable appears on top of the outer one. Writing the code for the two cables in the opposite order puts the inner cable in an invisible position behind the outer one, an equally bad solution. Can someone fix this, that is, make it seem as if the inner cable is really within the outer one?

documentclass{memoir}

usepackage{tikz,pgfplots}

begin{document}

begin{tikzpicture}
    begin{axis}[axis equal image]

    addplot3[surf,shader=interp,z buffer=sort,variable=u,variable y=v,domain=0:80, y domain=0:360] ({u},{13*cos(v)}, {13*sin(v)});

    addplot3[surf,shader=interp,z buffer=sort,variable=u,variable y=v,domain=0:80, y domain=0:360,colormap/cool] ({u},{4*cos(v)}, {4*sin(v)});
    end{axis}
    end{tikzpicture}

end{document}

enter image description here

One Answer

You can split the outer cable as suggested by Jake.

documentclass{memoir}

usepackage{pgfplots}
pgfplotsset{compat=1.11}

begin{document}

begin{tikzpicture}
  begin{axis}[axis equal image]

       addplot3[surf,shader=interp,z buffer=sort,variable=u,variable y=v,domain=0:80,
                    y domain=-90:90] ({u},{13*cos(v)}, {13*sin(v)});
       addplot3[surf,shader=interp,z buffer=sort,variable=u,variable y=v,domain=0:80,
                    y domain=0:360,colormap/cool] ({u},{4*cos(v)}, {4*sin(v)});
       addplot3[surf,shader=interp,z buffer=sort,variable=u,variable y=v,domain=0:80,
                    y domain=90:270] ({u},{13*cos(v)}, {13*sin(v)});
    end{axis}
   end{tikzpicture}

end{document}

enter image description here

With hide axis:

enter image description here

Correct answer by user11232 on March 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP