Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to make a Mexican hat potential (like this one from Wikipedia)

enter image description here

drawing through TikZ, and I am sure the function to use is straightforward, but I have not managed to find the right solution myself... !

I am using this as a starting point, just need the right function...

\tdplotsetmaincoords{70}{135}
\tdplotsetpolarplotrange{90}{180}{0}{360}
\begin{tikzpicture}[line join=bevel,tdplot_main_coords, fill opacity=.7]
\tdplotsphericalsurfaceplot[parametricfill]{72}{36}%
{4}{black}{\tdplottheta}%
{\draw[color=black,thick,->] (0,0,0) -- (20,0,0) node[anchor=north east]{$x$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,20,0) node[anchor=north west]{$y$};}%
{\draw[color=black,thick,->] (0,0,0) -- (0,0,3) node[anchor=south]{$z$};}%
\end{tikzpicture}

Any hints will be gratefully appreciated!!


Thanks again!

I now have a little problem getting the axis right. I want them placed in the middle of the plot, but I cannot seem to get the labels correct? Also, I would like to rotate the axis so that the x,y arrows point towards us, and the z up as it is now. Any tips? This is what I have now:

\pgfplotsset{
   standard/.style={
    axis x line=middle,
    axis y line=middle,
    axis z line=middle,
    enlarge x limits=0.15,
    enlarge y limits=0.15,
    enlarge x limits=0.15,
    every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
    every axis y label/.style={at={(current axis.above origin)},anchor=north east},
    every axis z label/.style={at={(current axis.above origin)},anchor=south}
}
}

\begin{tikzpicture}
 \begin{axis}[
 standard,
        colormap={blackwhite}{gray(0cm)=(1); gray(1cm)=(0)},
        samples=30,
        domain=0:360,
        y domain=0:1.25,
        zmin=0,
        zmax=2,
        xlabel=$\mathcal{RE}\,(\phi)$,
        ylabel=$\mathcal{IM}\,(\phi)$,
        zlabel=$V$,
        yticklabels={,,},
        xticklabels={,,},
        zticklabels={,,}
    ]
     \addplot3 [surf, shader=flat, draw=black,  z buffer=sort] ({sin(x)*y}, {cos(x)*y}, {(y^2-1)^2});
      %\addplot3 [surf, shader=flat, draw=black, fill=white, z buffer=sort] (x^4-x^2, y^4-y^2, 1);
    \end{axis}
\end{tikzpicture}

It produces the following figure:

enter image description here

But as you see the axis labelling is not optimal, and the axis is rotated the wrong direction..

Thanks so much so far!

share|improve this question
    
Related: Mexican hat in TikZ. –  Peter Grill Jan 24 '13 at 20:48

1 Answer 1

PGFPlots can plot 3D parametric functions. Here's the output using the function that is used for the Wikipedia image:

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            hide axis,
            samples=30,
            domain=0:360,
            y domain=0:1.25
        ]
        \addplot3 [surf, shader=flat, draw=black, fill=white, z buffer=sort] ({sin(x)*y}, {cos(x)*y}, {(y^2-1)^2});
        \end{axis}
    \end{tikzpicture}
\end{document}
share|improve this answer
    
This is very nice. –  Pouya Jan 24 '13 at 20:49
    
+1. How could I not discovered this before? –  Sigur Jan 24 '13 at 20:52
1  
Awesome, Jake! :) Soundtrack while running this example. :) –  Paulo Cereda Jan 24 '13 at 20:57
1  
Thanks a lot! I will try to modify this to my liking instead of using 3dplot, then, and use pgfplots. –  user24949 Jan 24 '13 at 21:07
    
@user24949: Glad that it helps! If you consider this question answered, you can mark it as such by clicking the tick mark next to my answer. –  Jake Jan 24 '13 at 22:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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