0

I am trying to reproduce the following type of histogram. One where I can apply "shading" of a region and standard units. Any help would be greatly appreciated.

enter image description here

  • 1
    Welcome to TeX.SE! You probably want to use something like pgfplots, and maybe this answer is worth a look: https://tex.stackexchange.com/questions/43610/plotting-bell-shaped-curve-in-tikz-pgf – rbrignall Jan 28 '20 at 22:56

1 Answers1

2

Just define a pic for the repeating parts and put those pics in a matrix.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}[declare function={gauss(\x)=exp(-\x*\x/2);},
 pics/fg/.style={code={\tikzset{fg/.cd,#1}
  \def\pv##1{\pgfkeysvalueof{/tikz/fg/##1}}
  \path[pattern=north east lines] 
    plot[smooth,variable=\x,domain=\pv{xmin}:\pv{xmax}] ({\x},{gauss(\x)})
    |- (\pv{xmin},0);
  \draw (-2.2,0) -- (2.2,0) (2,0) -- (2,-0.2) node[below]{$2$}
  (0,-0.2) node[below]{$0$} -- (0,{gauss(0)});
  \draw[thick] plot[smooth,variable=\x,domain=-2.2:2.2] ({\x},{gauss(\x)});
 }},fg/.cd,xmin/.initial=-2.2,xmax/.initial=2.2]
\matrix{
\pic{fg={xmax=2}}; & \node[text depth=1cm]{$=$}; &
\pic{fg={xmax=0}}; & \node[text depth=1cm]{$+$}; &
\pic{fg={xmin=0,xmax=2}};\\
};
\end{tikzpicture}
\end{document}

enter image description here

  • Thanks! I tried to adjust the values in your example and produce the following examples https://i.imgur.com/rKVaK0w.png with no luck. If I could trouble you with once more request to make these? –  Jan 30 '20 at 05:37
  • 1
    @Mr.1.0 \matrix{ \pic{fg={xmax=-1}}; \pic{fg={xmin=1}};& \node[text depth=1cm]{$=$}; & \pic{fg={xmax=-1}}; & \node[text depth=1cm]{$+$}; & \pic{fg={xmin=1}};\\ }; –  Jan 30 '20 at 05:40