I am drawing some graphs with tangents. I calculated the tangent should be centered at x=57/27
which is approximately x=2.11
. I'm currently using the pos
and sloped
keys for nodes to draw tangents, but I'm not happy about the result; the tangents don't really align.
I think this is because the pos
key calculates the actual length of the graph while the graphs don't have the same length.
I'm sure I can somehow let LaTeX
do the calculations for me so as to align the slopes vertically at an x
value of my choice. But how?
PS: The below document requires a working installation of gnuplot
to compile.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usetikzlibrary{arrows, decorations.markings,intersections}
\makeatletter
\tikzset{
nomorepostaction/.code=\makeatletter\let\tikz@postactions\pgfutil@empty,
my axis/.style={
postaction={
decoration={
markings,
mark=at position 1 with {
\arrow[ultra thick]{latex}
}
},
decorate,
nomorepostaction
},
thin,
-,
every path/.append style=my axis
}
}
\makeatother
\definecolor{headtitle}{RGB}{167,63,63}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
axis line style={my axis},
xlabel = $U_A$,
ylabel = $S$,
xmin = 0, xmax = 3.25,
ymin = 0,
xtick={1,1.5},
xticklabels={$U_{B,\mathrm{initial}}$,$U_{A,\mathrm{initial}}$},
xticklabel style={
inner sep=0pt,
anchor=north east,
rotate=35
},
ytick=\empty,
height=.66\linewidth, width=\linewidth-4.5\tabcolsep,
axis lines*=left,
every axis y label/.style={at=(current axis.above origin),anchor=east},
every axis x label/.style={at=(current axis.right of origin),anchor=west}]%
\addplot+[mark={},draw=headtitle] gnuplot[raw gnuplot] {%
set samples 51;
plot [0:3] log(3*(3-x)+1);
} node[sloped,above,pos=.63333,
minimum height=1cm,minimum width=1cm] (SB) {} node[pos=0.6,pin=45:{\color{black}{$S_B$}}] {};
\addplot+[mark={},draw=headtitle] gnuplot[raw gnuplot] {%
set samples 51;
plot [0:3] log(9*x^2+6*x+1);
} node[sloped,above,pos=.83333,
minimum height=1cm,minimum width=1cm] (SA) {} node[pos=0.25,pin=-15:{\color{black}{$S_A$}}] {};
\addplot+[mark={},draw=headtitle] gnuplot[raw gnuplot] {%
set samples 51;
plot [0:3] log(9*x^2+6*x+1)+log(3*(3-x)+1);
} node[sloped,above,pos=.775,
minimum height=1cm,minimum width=1cm] (St) {} node[pos=0.525,pin=165:{\color{black}{$S_\mathrm{total}$}}] {};
\path (SB.south east) edge[headtitle,very thick] node {} (SB.south west);
\path (SA.south east) edge[headtitle,very thick] node {} (SA.south west);
\path (St.south east) edge[headtitle,very thick] node {} (St.south west);
\end{axis}%
\end{tikzpicture}%
\end{document}