I would like to generate four hyperbolas in the plane and label them. I'm using the following code (sorry for its length, feel free to shorten it...):
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.9}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
every inner x axis line/.append style={help lines},
every inner y axis line/.append style={help lines},
every axis label/.append style={gray},
axis lines = center,
xtick = \empty,ytick=\empty,
xlabel={\tiny$x$},ylabel={\tiny$y$},
enlargelimits=auto
]
\addplot+[mark=none,red!80!black] function[raw gnuplot] {
set xrange [-5:5];
set yrange [-5:5];
set contour base;
set cntrparam levels discrete 0.0;
unset surface;
set view map;
set isosamples 70;
splot x*x/0.5-y*y/1.25-1;
} node[pos=0.4999,sloped,below]{\tiny$\frac{x^2}{a^2} - \frac{y^2}{b^2} = 1$};
\addplot+[mark=none,red!90] function[raw gnuplot] {
set xrange [-5:5];
set yrange [-5:5];
set contour base;
set cntrparam levels discrete 0.0;
unset surface;
set view map;
set isosamples 70;
splot x*x/0.5-y*y/1.25+1;
} node[pos=0.95,sloped,below]{\tiny$\frac{x^2}{a^2} - \frac{y^2}{b^2} = -1$};
\addplot+[mark=none,blue!80!black] function[raw gnuplot] {
set xrange [-5:5];
set yrange [-5:5];
set contour base;
set cntrparam levels discrete 0.0;
unset surface;
set view map;
set isosamples 70;
splot x*x/1.25-y*y/0.5-1;
} node[pos=0.9999,sloped,below]{\tiny$\frac{x^2}{b^2} - \frac{y^2}{a^2} = 1$};
\addplot+[mark=none,blue!80] function[raw gnuplot] {
set xrange [-5:5];
set yrange [-5:5];
set contour base;
set cntrparam levels discrete 0.0;
unset surface;
set view map;
set isosamples 70;
splot x*x/1.25-y*y/0.5+1;
} node[pos=0.6,sloped,below]{\tiny$\frac{x^2}{b^2} - \frac{y^2}{a^2} = -1$};
\end{axis}
\end{tikzpicture}
\end{document}
My problem is the placement of the labels. I'm trying to tweak the pos= key, but I never manage to find the right position. I guess that because of its branching behavior it is jumping around unexpectedly. I can only find a satisfying positioning for 3 out of the four. What is the right way to label the hyperbolas? I considered using absolute positioning, but I hope there's a nicer way out.


axis cs. I am wondering whether there is some better way. – Dror Nov 04 '13 at 10:54