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
3

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

2
  • Thanks! I tried to adjust the values in your example and produce the following examples i.imgur.com/rKVaK0w.png with no luck. If I could trouble you with once more request to make these? – Mr. 1.0 Jan 30 '20 at 5: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}};\\ }; – user194703 Jan 30 '20 at 5:40

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.