TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

mexican hat

in TikZ?

share|improve this question
Related Question: How to draw a “mexican hat potential” using 3dplot?. – Peter Grill Jan 24 '13 at 20:52
up vote 2 down vote accepted

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

share|improve this answer
But in your code the function used for the upper part of the hat goes upwards, so you really don't get a hat. – Gonzalo Medina 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. – Willem Van Onsem Apr 3 '11 at 2:12
Thank you, CommuSoft, this is very close to what I needed! – Thanos D. Papaïoannou 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

share|improve this answer
By the way, I'd like to draw your attention to a question about TikZ on meta: meta.tex.stackexchange.com/q/1220/86 – Loop Space Apr 3 '11 at 18:57
Thank you, Gonzalo, only your solution makes the hat slightly too pointy for my purposes. – Thanos D. Papaïoannou Apr 3 '11 at 23:44
@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. – Gonzalo Medina Apr 4 '11 at 1:04

Your Answer


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.