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.
-
1Welcome to TeX.SE! You probably want to use something like pgfplots, and maybe this answer is worth a look: tex.stackexchange.com/questions/43610/…– rbrignallJan 28, 2020 at 22:56
1 Answer
Just define a pic
for the repeating parts and put those pic
s 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}
-
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.0Jan 30, 2020 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}};\\ };
– user194703Jan 30, 2020 at 5:40