How would we typeset a “mexican hat” like the following

mexican hat

in TikZ?


Well the top of the hat looks like a statistical normal distribution. So I would plot that function. Furthermore you could use an arc for the upper part of the hat. And at last you could use a curve for the lower part of the hat. I have tried producing the hat with the following code:

\draw[very thick,domain=-1.5:1.5,xscale=0.5,smooth,variable=\x] plot ({\x},{(1.3*2.718281828^(-0.5*\x*\x))});
\draw[very thick] (0,-0 cm) arc (-90:70:1.5 cm and 0.4 cm);
\draw[very thick] (0,-0 cm) arc (270:110:1.5 cm and 0.4 cm);
\begin{scope}[yshift=0.4 cm]
\draw[very thick] (-10 : -1.5 cm and 0.4 cm) .. controls (-1.25,-0.8) and (1.25,-0.8) .. (-170 : -1.5 cm and 0.4 cm);

I agree it's not perfect, but feel free to improve. :D

  • 1
    But in your code the function used for the upper part of the hat goes upwards, so you really don't get a hat. Apr 3 '11 at 1:21
  • I'v compiled it with my Linux machine, it displayed a hat. I work from the bottom of the ellipse and arc it to the hat. However I dont see why you would draw this with TikZ. You can use an online vectorizer, to make it vectorized and import it in your pdf using includegraphics. Apr 3 '11 at 2:12
  • Thank you, CommuSoft, this is very close to what I needed! Apr 3 '11 at 23:44

I used arcs and a sin, cos combination to draw the hat (feel free to improve it):



\begin{tikzpicture}[ultra thick]
  \draw (2,-1.5) cos (3,0) sin (4,1.5) cos (5,0) sin (6,-1.5);
  \draw (2.4,-0.5) arc (114:428:4cm and 1cm);
  \draw (.55,-2.5) arc (210:330:4cm and 1cm);
  \draw (0.02,-1.45) arc (180:245:1.25cm);
  \draw (7.3,-2.57) arc (295:360:1.25cm);


mexican hat

  • By the way, I'd like to draw your attention to a question about TikZ on meta: meta.tex.stackexchange.com/q/1220/86 Apr 3 '11 at 18:57
  • Thank you, Gonzalo, only your solution makes the hat slightly too pointy for my purposes. Apr 3 '11 at 23:44
  • 1
    @Thanos D. Papaïoannou: you can change the top of the hat modifying the sin cos combination; you could use, for example, \draw (2,-1.5) cos (2.8,-0.5) sin (4,0.9) cos (5.2,-0.5) sin (6,-1.5); instead of the corresponding line of my code. Apr 4 '11 at 1:04

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.