# asymptotes of a hyperbola

Im trying to do a hyperbola with the a tangent in the middle, more or less like this, centered in x=4 and y=3

but I can get only this

the MWE is

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{datavisualization.formats.functions}
\begin{document}

\begin{tikzpicture}
\datavisualization[
school book axes,
visualize as smooth line/.list={left,right},
x axis={length=6cm, ticks and grid={major also at=4}},
y axis={length=6cm, ticks={some}},
data/format=function
]
data[set=left] {
var x : interval [0:3.9] samples 84;
func y = 1 / (\value x - 4);
}
data[set=right] {
var x : interval[4.1:8] samples 84;
func y = 1 / (\value x - 4);
};
\end{tikzpicture}

\end{document}


I usually give the trigonometric functions arguments in degress, but lately it seems to work without a domain, and went well too. But this time seems not to work the tangent- The main problem is that I cant work the hyperbola to get up to y=3. Perhaps it is needs to declare the axis section, but I wonder if this will conflict with the custom definitions of the hyperbola thingys.

• You just need to add 3 to the expression for y; then, when x goes to infinity, y goes to 3. – Daniel N Jan 21 at 22:08
• I was doing that way, but the asypmtotes remained the same – riccs_0x Jan 21 at 23:07

I propose the solution below. It is based on pgfplots.

• I tried to figure out the functions you are interested in from your code.
• It is a good practice to use the same technique for similar things (here the two graphs).
• It is better to give the domain for your graphs; in this way, you control what you are doing.

The code

\documentclass[border=1cm]{standalone}

\usepackage{tikz}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
font=\scriptsize,
axis background style={fill=gray!5},
grid=major,
grid style={color=gray!50},
xtick={0,1,...,8},
ytick={-6,-3,...,12},
axis lines=center
]
domain=-.2:{.86+pi/2}, samples=100] {-tan(deg(x-1))};
domain={1.08+pi/2}:{.86+3*pi/2}, samples=100] {-tan(deg(x-1))};