I have plot of y = 2 log_{2}(x), or equivalently, a plot of y = (2/ln(2))ln(x), a tangent line at (4,4), and a secant line through (4,4) and (16,8). I draw two "pins" to label these lines. The slopes of each are perpendicular to their respective lines. I would like them to be the same length - without a tedious calculation. How can I make them both the same length - maybe 0.75cm long?
I suspect that drawing this using the canvas coordinate system would be the most efficient. I have also seen an option for pin in a node command in pgfplots, and mathtools can be used to give me the "pins" perpendicular to the given lines.
\documentclass{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,intersections}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepackage{mathtools,array}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=5in, height=2.5in, clip=false,
axis lines=middle,
xmin=-4,xmax=32,
ymin=-6,ymax=16,
restrict y to domain=-6:16,
xtick={4,8.6562,16}, ytick={\empty},
ticklabel style={font=\tiny,fill=white},
xticklabels={$a$, $c$, $x_{\circ}$},
xlabel=$x$,ylabel=$y$,
axis line style={latex-latex},
axis line style={shorten >=-12.5pt, shorten <=-12.5pt, latex-latex},
xlabel style={at={(ticklabel* cs:1)}, xshift=12.5pt, anchor=north west},
ylabel style={at={(ticklabel* cs:1)}, yshift=12.5pt, anchor=south west}
]
\addplot[samples=501, name path=a_logarithm_function, domain=1/2^6:32]{2*log2(x)} node[right, pos=1, font=\footnotesize]{\makebox[0pt][l]{$y = f(x)$}};
%A secant line segment is drawn between (4,4) and (16,8).
\addplot[samples=2, dashed, domain=4:16] {(1/3)*x + 8/3};
%A tangent line at (4,4) is drawn; the slope of it is 1/(2 ln(2)).
\addplot[samples=2, latex-latex, domain=-4:{4+24*ln(2)}] {(1/(2*ln(2)))*x - 2/ln(2) + 4};
\addplot[samples=2, latex-latex, domain=-4:32] {(1/3)*x - 2/ln(2) + (2/ln(2))*ln(6/ln(2))};
%A "pin" is drawn to the tangent line at (a, f(a)). It is to be
%perpendicular to it; so, its slope is -2ln(2) = 2ln(1/2).
\addplot[samples=2, domain={16-0.15}:{16-2/3}] {2*ln(1/2)*x + 32*ln(2) + 6/ln(2) + 4} node[anchor=east, pos=1, font=\footnotesize]{$y=f(a)+f^{\prime}(a)(x-a)$};
%A "pin" is drawn to the secant line. It is to be perpendicular to the %secant line; so, its slope is -3.
\addplot[samples=2, domain={10+0.15}:{10+2/3}] {-3*x + 36} node[right, pos=1, font=\footnotesize]{\makebox[0pt][l]{$y=f(a)+f^{\prime}(c)(x-a)$}};
\draw [fill] (4,4) circle [radius=1.5pt];
\draw [fill] ({6/ln(2)}, {(2/ln(2))*ln(6/ln(2))}) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}
\end{document}

\nodecommands.addplotis unnecessarily complicated for this, I think. – Alenanno Aug 27 '16 at 20:48pinin a node command will give me what I want - a "pin" perpendicular to the given lines. – user74973 Aug 27 '16 at 21:19mathtools, which it doesn't, but the OP seemed quite keen on that non-feature, anyway.) – cfr Sep 01 '16 at 23:18axisenvironment. – user74973 Sep 02 '16 at 17:20