With some effort, I was able to find a way to mark the intersection points between the Gaussian bell and the straight line.
Leaving aside the first point, I would need to project the two intersection points onto the abscissa axis. My idea is this: extract the x coordinate of the intersection point, called e.g. x_1
, and create a node at point (x_1,0)
.
Is it possible to accomplish such a thing?
Here my MWE
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\pgfmathdeclarefunction{gauss}{2}{%
\pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\newcommand*{\ShowIntersection}[2]{
\fill
[name intersections={of=#1 and #2, name=i, total=\t}]
[red, opacity=1, every node/.style={above left, black, opacity=1}]
\foreach \s in {1,...,\t}{(i-\s) circle (2pt)
node [above left] {\s}};
}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
yticklabels=\empty, xticklabels=\empty,
width=8cm,
height=6cm,
domain=-2:3, ymin = 0.07, xmin = -2, enlargelimits=upper,
xtick=\empty, ytick=\empty,
clip mode=individual,
xlabel={$T$}, ylabel={$\Delta T$},
]
\addplot[smooth,red,samples=50,domain=-2:3,name path=gaussian]{8 * gauss(1,0.75)};
\addplot[smooth,blue,name path=line]{x*1.13 + 1.36};
\ShowIntersection{gaussian}{line}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
2
or3
to the axis, something like\draw (i-2)--(i-2|-0,0);
will do it. If you want to write theT
value, it's another question.node [above left]
when you already said every node is above left?