# Drawing and labeling asymptotes

How do I label the asymptotes for the rational function y=(x+1)/(x-1)? I copied the code \draw[dashed,latex-latex] ({{1,0}}|-{{axis description cs:1,1}}) -- ({{1,0}}|-{{axis description cs:1,0}}) from another post. I looked in the manual for this coding. The only "thing" that I got from the manual is that "axis description cs" is some description of the "coordinate system (cs)" and that {1,1} refers to the upper right hand corner of some box. I think "|-" instructs TikZ to draw a perpendicular line.

I do not know how to modify the code to have TikZ draw the horizontal asymptote y=1. How do I put the labels "x=1" at the bottom arrowhead and "y=1" at the left arrowhead?

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}

\begin{document}

\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-15,xmax=15,
xlabel=$x$,ylabel=$y$,
ymin=-10,ymax=10,
restrict y to domain=-12:12,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={-3}
]
/pgfplots/xlabel shift={10pt};
\draw[dashed,shorten <=2ex, shorten >=2ex,latex-latex] ({{1,0}}|-{{axis description cs:1,1}}) -- ({{1,0}}|-{{axis description cs:1,0}});
\draw [fill=white] (-3,0.25) circle [radius=1.5pt] node[left]{};
\end{axis}
\end{tikzpicture}
\vskip0.25in

\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-15,xmax=15,
xlabel=$x$,ylabel=$y$,
ymin=-10,ymax=10,
restrict y to domain=-12:12,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={-1},ytick=\empty
]
/pgfplots/xlabel shift={10pt};
\draw[dashed,shorten <=2ex, shorten >=2ex,latex-latex] ({{1,0}}|-{{axis description cs:1,1}}) -- ({{1,0}}|-{{axis description cs:1,0}});
\end{axis}
\end{tikzpicture}

\end{document}


You can use a node to put x=1 and y=1. Further, to draw a horizontal line at y=1, you can use \addplot: like

\addplot[samples=200,dashed,latex-latex,domain=-17:17] {1}node[above,pos=0]{$y=1$};


Full code:

\documentclass[10pt]{amsart}
%\usepackage{tikz}      %% These are all not needed
%\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
%\usepackage{tkz-euclide}
%\usetkzobj{all}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

%\usepackage{amsmath}
%\usepackage{amsfonts}
%\usepackage{amssymb}
%\usepackage{amsthm}

\begin{document}

\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-15,xmax=15,
xlabel=$x$,ylabel=$y$,
ymin=-10,ymax=10,
restrict y to domain=-12:12,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={-3},
every axis y label/.style=
{at={(ticklabel cs:1.02,-12pt)},rotate=0,anchor=west},
every axis x label/.style={
at={(xticklabel cs:1.02,-8pt)},anchor=south},
]
/pgfplots/xlabel shift={10pt};
\draw[dashed,shorten <=2ex, shorten >=2ex,latex-latex] ({{1,0}}|-{{axis description cs:1,1}}) -- ({{1,0}}|-{{axis description cs:1,0}})node[right,pos=0.95]{$x=1$};
\draw [fill=white] (-3,0.25) circle [radius=1.5pt] node[left]{};
\addplot[samples=200,dashed,latex-latex,domain=-17:17] {1}node[above,pos=0]{$y=1$};
\end{axis}
\end{tikzpicture}
\vskip0.25in

\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-15,xmax=15,
xlabel=$x$,ylabel=$y$,
ymin=-10,ymax=10,
restrict y to domain=-12:12,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
xtick={-1},ytick=\empty,
every axis y label/.style=
{at={(ticklabel cs:1.02,0pt)},rotate=0,},
every axis x label/.style={
at={(xticklabel cs:1.02,-8pt)},anchor=south},
]
/pgfplots/xlabel shift={10pt};
\draw[dashed,shorten <=2ex, shorten >=2ex,latex-latex] ({{1,0}}|-{{axis description cs:1,1}}) -- ({{1,0}}|-{{axis description cs:1,0}})node[right,pos=0.95]{$x=1$};
\addplot[samples=200,dashed,latex-latex,domain=-17:17] {1}node[above,pos=0]{$y=1$};

\end{axis}
\end{tikzpicture}

\end{document}


• This is almost the graph that I want. I added the command rotate=90 to the option for the node labeling the vertical line x=1. This label is printed over the vertical line - near the bottom arrowhead. How do I move it rightward? I know that P |- Q instructs TikZ to account for the point at the intersection of the vertical line through P and the horizontal line through Q. In drawing the vertical line, I guess P is {1,0}. Why isn't this ordered pair in parentheses? What is the point Q? What is {axis description cs:1,1}? Why not use the code \draw (1,0) |- (1,1) -- (1,0) |- (1,-1)? – user143462 Sep 26 '14 at 13:13
• I have one other question. In my original code, you added every axis y label/.style={at=(ticklabel cs:1.02,-12pt)},rotate=0,anchor=west to the options for the axes. And you have one for the x-axis. Please describe the syntax to me. Do you have to have "rotate=0"? I would like the "x" slightly below the right arrowhead of the x-axis and the "y" slightly to the right of the y-axis. Please tell me how to do this. – user143462 Sep 26 '14 at 13:36
• @user143462 That is too many questions and I have only one answer. Refer pgfplots manual, search for those keywords and read. BTW, keep pgfmanual also open. – user11232 Sep 26 '14 at 14:25
• Wait. You edited my code with every axis y label/.style={at=(ticklabel cs:1.02,-12pt)},rotate=0,anchor=west. You must have the opinion that this would be nicer. Why do you think it is nicer? Why do you have "rotate=0"? – user143462 Sep 26 '14 at 15:02
• @user143462 I just wanted the x and y not overlapping with the arrow head. And rotate=0 was there just to show you how to rotate y in case if you want. – user11232 Sep 26 '14 at 22:48

The syntax (c1 |- c2) instructs TikZ to use the coordinate at the intersection of a vertical line through c1 and a horizontal line through c2. In other words: Start from c1 and go up or down (in y direction) until you are next to c2. This is the point you specify.

Analogously (c1 -| c2) intersects a horizontal line through c1 and a vertical line through c2.

This is explained in more detail in the PGF manual (not PGFplots manual) in section 13.3 Coordinates at Intersections.