18

My question

I can easily draw the normal distribution thanks to this answer by Jake. What about the ghost ?

enter image description here

Context

This image always breaks the ice when teaching probabilities :)

(Not that I care so much about it, but Halloween is getting closer too)

I presume it would be possible with Inkscape (but I am not familiar with it).

This answer by Paul Gaborit uses the hobby package I tried to adapt (poorly as you'll see, far too manual to be honnest) in my MWE.

I'd be happy to see different approaches too (pure tikz, pgfplot, other libraries...).

\documentclass[tikz]{standalone}
\usetikzlibrary{hobby}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[use Hobby shortcut]

\draw[ help lines, line width=0.1pt, blue, ] (-20, -20) grid[step={($(5, 5) - (0, 0)$)}] (60, 100);

\path (0,0) coordinate (z0) (10,10) coordinate (z1) (20,0) coordinate (z2) (30,10) coordinate (z3) (40,0) coordinate (z4) (50,10) coordinate (z5) (30,90) coordinate (z6) (0,70) coordinate (z7) (0,60) coordinate (z8) ; \draw[closed,black, line width= 3mm] (z0) .. (z1) .. (z2) .. (z3) .. (z4) .. (z5).. (z6).. (z7).. (z8); \end{tikzpicture} \end{document}

enter image description here

JeT
  • 3,020
  • 1
    Seeing that it's been 11 hours and no one else has nitpicked yet, I just had to remark that putting the two images side by side, could be seen as implying that the "Paranormal distribution" is also expected to be a 2d plot of a single variable probability density function, but of course it's not a function, with multiple y values for the same x. Therefore, to avoid any such confusion, I would recommend that we instead treat the "Paranormal Distribution" as a joint (bivariate) density function, which then has the added benefit of giving you a good reason to include colors ;) – yoniLavi Oct 08 '21 at 10:08
  • @yoniLavi a pgf answer that looks promising! – JeT Oct 08 '21 at 10:26
  • 1
    @yoniLavi Geogebra gives an idea on how to a a achieve an answer with pgfplot. – JeT Oct 09 '21 at 10:15

8 Answers8

29

This is my attempt, using TikZ and a lot of to[out=...,in=...]s.

\documentclass[border=2mm,tikz]{standalone}

\begin{document} \begin{tikzpicture}[thick,line cap=round] % grid %\draw[gray] (-5,0) grid[step=0.5] (5,13); % ghost 'body' \draw[line width=0.75mm] (0,1.5) to[out=0,in=180] (1.5,0) to[out=0 ,in=180] (3,2) to[out=0,in=135] (4,1.5) to[out=-45,in=-45,looseness=2] (4.5,2) to[out=135,in=270] (3,8) to[out=90 ,in=90 ,looseness=2.5] (-3,8) to[out=270,in=45] (-4.5,2) to[out=225,in=225,looseness=2] (-4,1.5) to[out=45 ,in=180] (-3,2) to[out=0 ,in=180] (-1.5,0) to[out=0 ,in=180] (0,1.5); % ghost eyes \foreach\i in {-1,1} {% \begin{scope}[shift={(\i-0.3,8.5)},rotate=\i*10] \fill ellipse (0.3 cm and 0.6 cm); \end{scope}} % axis \draw (-5.5,-1) -- (5.5,-1); \foreach\i in {-5,...,5} \draw (\i,-1) --++ (0,-0.2); \node at (0,-2) {\huge\bfseries Paranormal Distribution}; \end{tikzpicture} \end{document}

And the ghost: enter image description here

Edit. An animated ghost:

\documentclass    {beamer}
\usepackage       {tikz}
\setbeamertemplate{navigation symbols}{}

\begin{document} \begin{frame} \begin{figure}\centering \begin{tikzpicture}[thick,line cap=round,scale=0.5] \useasboundingbox (-8,0) rectangle (8,14); % fake normal distribution \foreach\j in {1,...,5} {% \pgfmathtruncatemacro\jj{20-\j} \only<\j,\jj> {% \pgfmathsetmacro\y{0.2(10-\j)} \draw plot[domain=-8:8,samples=81,smooth] (\x\y,{13/(1+0.07\x\x)}); } } % ghost \foreach\j in {6,...,14} {% \only<\j> {% \pgfmathsetmacro\y{0.05abs(10-\j)} % ghost 'body' \coordinate (A) at (0,1.5+\y); \coordinate (B) at (1.5,0); \coordinate (C) at (3,2+\y); \coordinate (D) at (4,1.5); \coordinate (E) at (4.5,2); \coordinate (F) at (-4.5,2); \coordinate (G) at (-4,1.5); \coordinate (H) at (-3,2+\y); \coordinate (I) at (-1.5,0); \draw[line width=0.5mm] (A) to[out=0,in=180] (B) to[out=0 ,in=180] (C) to[out=0,in=135] (D) to[out=-45,in=-45,looseness=2] (E) to[out=135,in=270] (3,8) to[out=90 ,in=90,looseness=2.5] (-3,8) to[out=270,in=45] (F) to[out=225,in=225,looseness=2] (G) to[out=45 ,in=180] (H) to[out=0 ,in=180] (I) to[out=0 ,in=180] (A); % ghost eyes \foreach\i in {-1,1} {% \begin{scope}[shift={(\i-3\y,8.5)},rotate=\i*10] \fill ellipse (0.3cm and 0.6cm); \end{scope} } } } % axis \draw (-8.5,-1) -- (8.5,-1); \foreach\i in {-8,...,8} \draw (\i,-1) --++ (0,-0.2); \node at (0,-2) {\huge\bfseries\strut \only<8-12>{p}% \only<7-13>{a}% \only<6-14>{r}% \only<5-15>{a}% normal distribution\strut}; \end{tikzpicture} \end{figure} \end{frame} \end{document}

enter image description here

Juan Castaño
  • 28,426
22

You could use the ghost from halloweenmath

\documentclass{article}
\usepackage{halloweenmath,graphicx}
\begin{document}
\resizebox{4cm}{!}{$\mathghost$}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
17

A quick suggestion with pure tikz:

\documentclass[border=6.66mm]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[smooth cycle]

    \draw[] plot[tension=1]
    coordinates{(0,0)  (1,1) (2,0) (3,1) (4,0) (4,4) (3,9) (0,2) (0,1)};

    %eyes
    \draw[fill=black,rotate around={-45:(2.3,7)}] (2.3,7) ellipse (2mm and 3.5mm);
    \draw[fill=black,rotate around={-45:(3.3,7)}] (3.3,7) ellipse (2mm and 3.5mm);

    %mouth [optional]
    \draw[fill=black,rotate around={-10:(3,5)}] (3,5) arc (0:-180:0.5cm and 3mm);

    \end{tikzpicture}

\end{document}

enter image description here

Roland
  • 6,655
11

With four parameters I can fit an elephant, and with five I can make him wiggle his trunk. John von Neumann

The trick with hobby is to start with a few points on the shape and then add more points where the curve deviates from the one wanted. The more points, the more specific the curve. With the ghost, the wiggly bottom edge clearly needs several points, and then there needs to be another on each side just above the bottom edge to get the sides under control, but the rest of the sides doesn't need any more points.

I used Drawing on an image with TikZ to define a coordinate system overlaying the original image to place the points. I've left this code in the document below (commented out). This does mean that the coordinates are specified on a small scale (since the coordinate system goes from (0,0) to (1,1)) but a suitable scale=20 fixes that.

\documentclass{article}
%\url{https://tex.stackexchange.com/q/618136/86}
\usepackage{tikz}
\usetikzlibrary{hobby}

\begin{document}

\begin{tikzpicture}[use Hobby shortcut] %\node[anchor=south west,inner sep=0pt] at (0,0) (ghost) {\includegraphics{ghost.png}}; %\begin{scope}[x={(ghost.south east)},y={(ghost.north west)}] %\draw[blue,ultra thin] (.3,.1) grid[step=.01] (.7,.6); %\draw[blue,ultra thick] (0,0) grid[step=.1] (1,1); \begin{scope}[scale=20] \draw[ultra thick] ([closed].5,.52) .. (.6,.28) .. (.625,.22) .. (.6,.21) .. (.58,.22) .. (.55,.17) .. (.5,.21) .. (.45,.17) .. (.43,.21) .. (.39,.195) .. (.4,.26) ;

\fill[black] (.515,.425) ellipse[x radius=.01, y radius=.02]; \fill[black] (.47,.425) ellipse[x radius=.01, y radius=.02];

\end{scope}

\end{tikzpicture} \end{document}

hobby ghost one

To make the top a little more curved, add points at (.53,.51) and (.47,.51) either side of the point at (.5,.52).

hobby ghost two

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751
9

A crazy ghost from the hell of the package twemojis.

\documentclass[12pt]{article}
\usepackage{twemojis,scalerel}
\begin{document}
\scaleobj{15}{\twemoji{ghost}}
\end{document}

enter image description here

Sebastiano
  • 54,118
5

Other ghost symbols from fontawesome5 and another done with TikZ.

\documentclass[a4paper,12pt]{article}
\usepackage{anyfontsize}
\usepackage{fontawesome5}
\usepackage[svgnames]{xcolor}

\begin{document} \textcolor{GhostWhite}{\fontsize{70}{60}\selectfont \faGhost} \end{document}

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usepackage{xcolor}

\newcommand{\ghost}[1]{\tikz[baseline=.2em,scale=8]{ \draw [fill=#1] (0,0) -- (0,.5) arc (+180:0:.3) -- (.6,0) -- (.5,.15) -- (.4,0) -- (.3,.15) -- (.2,0) -- (.1,.15) -- cycle; \coordinate (visual) at (360*rand:.03); \foreach \x in {.15,.4}{ \fill[black] (\x,.5) ++(visual) circle[radius=.07]; }}}

\begin{document} \ghost{white} \end{document}

enter image description here

Sebastiano
  • 54,118
4

Another suggestion is to convert your ghost in .svg and export in LaTeX making some changes: https://products.aspose.app/pdf/it/conversion/svg-to-tex. Here I have improved a bit the (very long) original code:

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[overlay]
 \path (0,0);
\filldraw[black][nonzero rule]
(176.7pt, -0.499985pt) .. controls (186.5pt, -5.399994pt) and (194.8pt, -17.09999pt) .. (198.3pt, -30.99998pt)
 -- (198.3pt, -30.99998pt)
 -- (198.3pt, -30.99998pt)
 -- (198.3pt, -30.99998pt) .. controls (199.2pt, -34.59999pt) and (200.7pt, -44.7pt) .. (201.6pt, -53.5pt)
 -- (201.6pt, -53.5pt)
 -- (201.6pt, -53.5pt)
 -- (201.6pt, -53.5pt) .. controls (204.3pt, -81.5pt) and (209.4pt, -99.8pt) .. (222.7pt, -129.8pt)
 -- (222.7pt, -129.8pt)
 -- (222.7pt, -129.8pt)
 -- (222.7pt, -129.8pt) .. controls (229.9pt, -146.2pt) and (230.6pt, -150.9pt) .. (226.5pt, -153.6pt)
 -- (226.5pt, -153.6pt)
 -- (226.5pt, -153.6pt)
 -- (226.5pt, -153.6pt) .. controls (223.3pt, -155.7pt) and (219.4pt, -155pt) .. (214pt, -151.4pt)
 -- (214pt, -151.4pt)
 -- (214pt, -151.4pt)
 -- (214pt, -151.4pt) .. controls (208.6pt, -147.8pt) and (205.6pt, -149pt) .. (204.6pt, -155pt)
 -- (204.6pt, -155pt)
 -- (204.6pt, -155pt)
 -- (204.6pt, -155pt) .. controls (203.5pt, -162.1pt) and (200pt, -171.4pt) .. (197.8pt, -173.3pt)
 -- (197.8pt, -173.3pt)
 -- (197.8pt, -173.3pt)
 -- (197.8pt, -173.3pt) .. controls (196.7pt, -174.2pt) and (194.2pt, -175pt) .. (192.3pt, -175pt)
 -- (192.3pt, -175pt)
 -- (192.3pt, -175pt)
 -- (192.3pt, -175pt) .. controls (188.5pt, -175pt) and (188.1pt, -174.6pt) .. (177.2pt, -162.2pt)
 -- (177.2pt, -162.2pt)
 -- (177.2pt, -162.2pt)
 -- (177.2pt, -162.2pt) .. controls (170.3pt, -154.3pt) and (168.6pt, -153.7pt) .. (162.4pt, -156.6pt)
 -- (162.4pt, -156.6pt)
 -- (162.4pt, -156.6pt)
 -- (162.4pt, -156.6pt) .. controls (160.5pt, -157.5pt) and (156.7pt, -161.1pt) .. (153.9pt, -164.6pt)
 -- (153.9pt, -164.6pt)
 -- (153.9pt, -164.6pt)
 -- (153.9pt, -164.6pt) .. controls (148.4pt, -171.5pt) and (146.5pt, -173pt) .. (142.7pt, -173pt)
 -- (142.7pt, -173pt)
 -- (142.7pt, -173pt)
 -- (142.7pt, -173pt) .. controls (138.9pt, -173pt) and (136.9pt, -169.9pt) .. (136.3pt, -162.8pt)
 -- (136.3pt, -162.8pt)
 -- (136.3pt, -162.8pt)
 -- (136.3pt, -162.8pt) .. controls (136pt, -159.3pt) and (135.3pt, -155.7pt) .. (134.8pt, -154.7pt)
 -- (134.8pt, -154.7pt)
 -- (134.8pt, -154.7pt)
 -- (134.8pt, -154.7pt) .. controls (133.4pt, -151.9pt) and (128.5pt, -152.7pt) .. (120.1pt, -157pt)
 -- (120.1pt, -157pt)
 -- (120.1pt, -157pt)
 -- (120.1pt, -157pt) .. controls (111.4pt, -161.5pt) and (109.1pt, -161.8pt) .. (106.6pt, -159.1pt)
 -- (106.6pt, -159.1pt)
 -- (106.6pt, -159.1pt)
 -- (106.6pt, -159.1pt) .. controls (103.8pt, -156pt) and (105.3pt, -150.9pt) .. (114pt, -133pt)
 -- (114pt, -133pt)
 -- (114pt, -133pt)
 -- (114pt, -133pt) .. controls (118.4pt, -124.2pt) and (122.6pt, -114.6pt) .. (123.5pt, -111.7pt)
 -- (123.5pt, -111.7pt)
 -- (123.5pt, -111.7pt)
 -- (123.5pt, -111.7pt) .. controls (126.9pt, -100.1pt) and (130.3pt, -74pt) .. (131.5pt, -50.29999pt)
 -- (131.5pt, -50.29999pt)
 -- (131.5pt, -50.29999pt)
 -- (131.5pt, -50.29999pt) .. controls (132.5pt, -30.29999pt) and (137.6pt, -16.29999pt) .. (147.4pt, -6.499985pt)
 -- (147.4pt, -6.499985pt)
 -- (147.4pt, -6.499985pt)
 -- (147.4pt, -6.499985pt) .. controls (156pt, 2.100006pt) and (166.9pt, 4.300003pt) .. (176.7pt, -0.499985pt) -- cycle
(157.7pt, 2.600006pt) .. controls (145.1pt, -2.099991pt) and (135.2pt, -15.59999pt) .. (131.4pt, -33.39999pt)
 -- (131.4pt, -33.39999pt)
 -- (131.4pt, -33.39999pt)
 -- (131.4pt, -33.39999pt) .. controls (130.6pt, -37.29999pt) and (129.5pt, -47.89999pt) .. (129pt, -57pt)
 -- (129pt, -57pt)
 -- (129pt, -57pt)
 -- (129pt, -57pt) .. controls (127.6pt, -81.4pt) and (124.9pt, -100.2pt) .. (120.9pt, -113pt)
 -- (120.9pt, -113pt)
 -- (120.9pt, -113pt)
 -- (120.9pt, -113pt) .. controls (119.7pt, -116.6pt) and (115.8pt, -125.3pt) .. (112pt, -132.5pt)
 -- (112pt, -132.5pt)
 -- (112pt, -132.5pt)
 -- (112pt, -132.5pt) .. controls (108.3pt, -139.7pt) and (104.7pt, -148.1pt) .. (104pt, -151.3pt)
 -- (104pt, -151.3pt)
 -- (104pt, -151.3pt)
 -- (104pt, -151.3pt) .. controls (102.8pt, -156.7pt) and (102.8pt, -157.3pt) .. (104.7pt, -159.8pt)
 -- (104.7pt, -159.8pt)
 -- (104.7pt, -159.8pt)
 -- (104.7pt, -159.8pt) .. controls (107.8pt, -164pt) and (111.6pt, -163.8pt) .. (120.6pt, -159pt)
 -- (120.6pt, -159pt)
 -- (120.6pt, -159pt)
 -- (120.6pt, -159pt) .. controls (125.3pt, -156.5pt) and (129.4pt, -155pt) .. (130.9pt, -155.2pt)
 -- (130.9pt, -155.2pt)
 -- (130.9pt, -155.2pt)
 -- (130.9pt, -155.2pt) .. controls (133.4pt, -155.5pt) and (133.5pt, -155.9pt) .. (134.2pt, -162.8pt)
 -- (134.2pt, -162.8pt)
 -- (134.2pt, -162.8pt)
 -- (134.2pt, -162.8pt) .. controls (135pt, -171.8pt) and (137.3pt, -175pt) .. (143.1pt, -175pt)
 -- (143.1pt, -175pt)
 -- (143.1pt, -175pt)
 -- (143.1pt, -175pt) .. controls (147.2pt, -175pt) and (149.7pt, -173.1pt) .. (156.4pt, -164.7pt)
 -- (156.4pt, -164.7pt)
 -- (156.4pt, -164.7pt)
 -- (156.4pt, -164.7pt) .. controls (160.5pt, -159.7pt) and (164.5pt, -157pt) .. (167.8pt, -157pt)
 -- (167.8pt, -157pt)
 -- (167.8pt, -157pt)
 -- (167.8pt, -157pt) .. controls (168.9pt, -157pt) and (171.9pt, -159.4pt) .. (174.6pt, -162.4pt)
 -- (174.6pt, -162.4pt)
 -- (174.6pt, -162.4pt)
 -- (174.6pt, -162.4pt) .. controls (177.3pt, -165.3pt) and (181.4pt, -169.8pt) .. (183.7pt, -172.4pt)
 -- (183.7pt, -172.4pt)
 -- (183.7pt, -172.4pt)
 -- (183.7pt, -172.4pt) .. controls (187.5pt, -176.5pt) and (188.4pt, -177pt) .. (192.2pt, -177pt)
 -- (192.2pt, -177pt)
 -- (192.2pt, -177pt)
 -- (192.2pt, -177pt) .. controls (194.6pt, -177pt) and (197.5pt, -176.3pt) .. (198.6pt, -175.5pt)
 -- (198.6pt, -175.5pt)
 -- (198.6pt, -175.5pt)
 -- (198.6pt, -175.5pt) .. controls (201.3pt, -173.7pt) and (204.5pt, -166.2pt) .. (206pt, -158.2pt)
 -- (206pt, -158.2pt)
 -- (206pt, -158.2pt)
 -- (206pt, -158.2pt) .. controls (206.7pt, -154.8pt) and (207.6pt, -151.7pt) .. (208pt, -151.5pt)
 -- (208pt, -151.5pt)
 -- (208pt, -151.5pt)
 -- (208pt, -151.5pt) .. controls (208.5pt, -151.2pt) and (211.4pt, -152.4pt) .. (214.5pt, -154pt)
 -- (214.5pt, -154pt)
 -- (214.5pt, -154pt)
 -- (214.5pt, -154pt) .. controls (221.2pt, -157.5pt) and (223.4pt, -157.7pt) .. (227.9pt, -154.9pt)
 -- (227.9pt, -154.9pt)
 -- (227.9pt, -154.9pt)
 -- (227.9pt, -154.9pt) .. controls (231.2pt, -152.9pt) and (231.2pt, -152.8pt) .. (230.8pt, -147.2pt)
 -- (230.8pt, -147.2pt)
 -- (230.8pt, -147.2pt)
 -- (230.8pt, -147.2pt) .. controls (230.5pt, -143pt) and (228.9pt, -138.3pt) .. (224.6pt, -129.1pt)
 -- (224.6pt, -129.1pt)
 -- (224.6pt, -129.1pt)
 -- (224.6pt, -129.1pt) .. controls (218.1pt, -115.1pt) and (210pt, -91.9pt) .. (207.1pt, -78.5pt)
 -- (207.1pt, -78.5pt)
 -- (207.1pt, -78.5pt)
 -- (207.1pt, -78.5pt) .. controls (206pt, -73.5pt) and (204.4pt, -62.09999pt) .. (203.5pt, -53pt)
 -- (203.5pt, -53pt)
 -- (203.5pt, -53pt)
 -- (203.5pt, -53pt) .. controls (202.6pt, -43.89999pt) and (201.2pt, -33.79999pt) .. (200.4pt, -30.49998pt)
 -- (200.4pt, -30.49998pt)
 -- (200.4pt, -30.49998pt)
 -- (200.4pt, -30.49998pt) .. controls (196.8pt, -16.49998pt) and (188pt, -3.799988pt) .. (178.4pt, 1.000015pt)
 -- (178.4pt, 1.000015pt)
 -- (178.4pt, 1.000015pt)
 -- (178.4pt, 1.000015pt) .. controls (172.5pt, 3.900009pt) and (163.2pt, 4.700012pt) .. (157.7pt, 2.600006pt) -- cycle
;
\filldraw[black][nonzero rule]
(149.4pt, -35.49998pt) .. controls (147pt, -39.2pt) and (146pt, -45.89999pt) .. (147.1pt, -50.29999pt)
 -- (147.1pt, -50.29999pt)
 -- (147.1pt, -50.29999pt)
 -- (147.1pt, -50.29999pt) .. controls (149.1pt, -57.89999pt) and (153.9pt, -55.5pt) .. (156.1pt, -45.59999pt)
 -- (156.1pt, -45.59999pt)
 -- (156.1pt, -45.59999pt)
 -- (156.1pt, -45.59999pt) .. controls (158.2pt, -35.89999pt) and (153.7pt, -28.99998pt) .. (149.4pt, -35.49998pt) -- cycle
;
\filldraw[black][nonzero rule]
(172.6pt, -35.2pt) .. controls (169.3pt, -39.79999pt) and (171.6pt, -53.89999pt) .. (175.8pt, -55.5pt)
 -- (175.8pt, -55.5pt)
 -- (175.8pt, -55.5pt)
 -- (175.8pt, -55.5pt) .. controls (180.1pt, -57.09999pt) and (182.4pt, -47.09999pt) .. (179.5pt, -39.49998pt)
 -- (179.5pt, -39.49998pt)
 -- (179.5pt, -39.49998pt)
 -- (179.5pt, -39.49998pt) .. controls (177.3pt, -33.7pt) and (174.7pt, -32.09999pt) .. (172.6pt, -35.2pt) -- cycle
;
\draw    (15,233) -- (323,233) (46,229) -- (46,237)(77,229) -- (77,237)(108,229) -- (108,237)(139,229) -- (139,237)(170,229) -- (170,237)(201,229) -- (201,237)(232,229) -- (232,237)(263,229) -- (263,237)(294,229) -- (294,237) ;
\end{tikzpicture}
\end{document}

enter image description here

JeT
  • 3,020
Sebastiano
  • 54,118
4

My (very) improvable attempt with pgfplot.

Thanks to all the great previous answers and Geogebra, It helped me having a more precise idea.

enter image description here

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{shapes}
\pgfplotsset{compat=1.17}

\begin{document} \begin{tikzpicture}[ countour/.style={line width=1.5pt,domain=-2.5:2.95}, eyes/.style={scale=0.6,ellipse,fill=black,minimum height=10pt,,rotate=90}, declare function={ wave(\x) = 0.05 * sin(260\x) -0.03 ; Gauss(\x) = 1/(sqrt(2pi))exp(-0.5(pow(\x,2))); } ] \begin{axis}[samples = 100] \addplot[countour] {Gauss(x)}; \addplot[countour] {wave(x)}; \node[eyes] at (axis cs:-0.4, 0.23) {aa} ;
\node[eyes] at (axis cs:0.4, 0.23) {aa} ;
\end{axis} \end{tikzpicture} \end{document}

enter image description here

JeT
  • 3,020