2

I am trying to illustrate limits in R^2 to my students. In doing so I created the following figure in Geogebra

enter image description here

Where the idea is that when you approach origo along the black and purple lines you reach 0. However riding along the ridge we instead reach some height above 0. As such the red domain is not continuous.

I tried to recreate the figure above using pgfplots however the result where somewhat appalling.

enter image description here

I do not think that it matters but the red figure is the function

f(x,y) = x y^3 /( 3y^2 + x^6)

restricted to the unit circle. Some of the problems is that it looks like the white line in the pgfplots image goes above the ridge and breaks the illusion. Any better way of illustrating the function above than my attempt?

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[view = {-35}{35}]
     \addplot3[
         surf,
         colormap/cool,
         samples=50,
         domain=0:1,
         y domain=0:2*pi,
         z buffer=sort
       ]
       ( {x*cos(deg(y))}, 
         {x*sin(deg(y))}, 
         {x*sin(deg(y))*(x*cos(deg(y)))^3/(3*(x*sin(deg(y)))^2 + (x*cos(deg(y)))^6}
         );
         \addplot3[variable=u,color=green,mesh,domain=-1:1] (u,u^3, 1/4);
         \addplot3[variable=u,color=black,domain=-1:1] (u,0, 0);
         \addplot3[variable=u,color=pink,domain=-1:1] (0,u, 0);
  \end{axis}
\end{tikzpicture}
\end{document}
  • 1
    You can fix this by drawing the plot in pieces and on different layers, see e.g. here. Or switch to asymptote. – user121799 Apr 4 '18 at 21:33
1

Certainly not a complete answer, but just spelling out my comment a tiny bit.

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.15}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[view = {-35}{35},axis on top,ticks=none,axis lines=center, 
  set layers=default,xlabel={$x$}, ylabel={$y$}, zlabel={$z$},
    xlabel style={anchor=south east},
    ylabel style={anchor=south west},
    zlabel style={anchor=south west},
    xmin=-1.25,xmax=1.25,ymin=-1.25,ymax=1.25] %<-added, this also sets layers
    \addplot3[variable=u,black,domain=-1.25:1.25] (0,u, 0);
     \addplot3[
         surf,
         colormap/cool,
         samples=50,
         domain=0:1,
         y domain=0:2*pi,
         on layer=axis foreground, %<-added
         opacity=0.6, %<-added
         z buffer=sort,
       ]
       ( {x*cos(deg(y))}, 
         {x*sin(deg(y))}, 
         {x*sin(deg(y))*(x*cos(deg(y)))^3/(3*(x*sin(deg(y)))^2 + (x*cos(deg(y)))^6}
         );
         \addplot3[variable=u,color=black,domain=-1.25:-0.195,on layer=axis foreground] (u,0, 0);
         \addplot3[variable=u,color=green,mesh,domain=-1:1,
         on layer=axis foreground] (u,u^3, 1/4);
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

The only thing I did is to make the x-axis more 3D-like.

| improve this answer | |

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.