5

I am trying to draw a red border of a Moebius strip. I have tried several things, playing with shader=faceted and mesh but I could not achieve this.

enter image description here

The code :

\documentclass[english]{article}
\usepackage{pgf,pgfplots}
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
    hide axis,
    view = {40}{40}
    ]
    \addplot3 [
    surf,
    colormap={blackwhite}{gray(0cm)=(1); gray(1cm)=(0.5)},
    shader     = faceted interp,opacity = 0.7,
    %shader = interp,
    point meta = x,
    samples    = 40,
    samples y  = 4,
    z buffer   = sort,
    domain     = 0:360,
    y domain   =-0.5:0.5
    ] (
    {(1+0.5*y*cos(x/2)))*cos(x)},
    {(1+0.5*y*cos(x/2)))*sin(x)},
    {0.5*y*sin(x/2)}
    );
    \end{axis}
    \end{tikzpicture}
\end{document}

Do you have an idea?

4

Welcome to TeX-SE! You could just draw the contours separately.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
 \begin{tikzpicture}
    \begin{axis}[
    hide axis,
    view = {40}{40}
    ]
    \addplot3 [color=blue,thick,    
    domain     = 360:720,samples y=0,
    ] (
    {(1+0.5*0.5*cos(x/2)))*cos(x)},
    {(1+0.5*0.5*cos(x/2)))*sin(x)},
    {0.5*0.5*sin(x/2)}
    );
    \addplot3 [
    surf,
    colormap={blackwhite}{gray(0cm)=(1); gray(1cm)=(0.5)},
    shader     = faceted interp,opacity = 0.7,
    %shader = interp,
    point meta = x,
    samples    = 40,
    samples y  = 4,
    z buffer   = sort,
    domain     = 0:360,
    y domain   =-0.5:0.5
    ] (
    {(1+0.5*y*cos(x/2)))*cos(x)},
    {(1+0.5*y*cos(x/2)))*sin(x)},
    {0.5*y*sin(x/2)}
    );
    \addplot3 [color=blue,thick,    
    domain     = -140:497.5,samples y=0,samples=(640/360)*24+1,
    ] (
    {(1+0.5*0.5*cos(x/2)))*cos(x)},
    {(1+0.5*0.5*cos(x/2)))*sin(x)},
    {0.5*0.5*sin(x/2)}
    );
    \end{axis}
 \end{tikzpicture}
\end{document}

enter image description here

  • 2
    where is the duck? tex.stackexchange.com/a/424140/2388 – Ulrike Fischer Jun 21 at 15:02
  • 1
    @UlrikeFischer AFAIK the duck got eaten by the Bär. – user121799 Jun 21 at 15:05
  • 4
    I would give a +1 if you used a different colour for each edge. – David Carlisle Jun 21 at 15:15
  • 4
    @DavidCarlisle The color is entirely fixed by the user name of the OP, so that is not possible. – user121799 Jun 21 at 15:18

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.