# Fitting the asymptotes and graph of a function onto the pictured Cartesian plane using pgfplots

I would like the code that instructs TikZ to plot the asymptotes to the graph for the rational function y=(x+2)/(x-1). What is the code for plotting these lines as a dashed lines with arrowheads? (I am removing the point (-3, 0.25) from the graph.) These should be a little shorter than the axes.

I would like more of the function to be graphed. I specified that the domain should be from -15 to 15, except for an interval near 1. It does not look like it is all graphed. I would also like to extend the y-axis in both directions so that the graph fits on the pictured Cartesian plane.

I would like one tick mark on the x-axis: -3. It should be typeset in a small font. I used tick style={font=\small} but it didn't change the font. I don't want the tick marks on the y-axis.

Only give code using pgfplots.

\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,
ymin=-5,ymax=5,
enlargelimits={abs=1cm},
axis line style={latex-latex},
tick style={font=\small},
ticklabel style={fill=white},
xtick={-3}
]

% Draw the two parts separately with individual domains:
\draw [fill=white] (-3,0.25) circle [radius=1.5pt] node[left]{};
\end{axis}

\end{tikzpicture}


I don't know exactly what you are trying to do but this is what I've understood.

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=4in,axis equal image,
axis lines=middle,
xmin=-15,xmax=15,
ymin=-5,ymax=5,
restrict y to domain=-10:10,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={font=\tiny,fill=white},
ytick=\empty,xtick={-2}
]
\draw[dashed,latex-latex] ({{1,0}}|-{{axis description cs:1,1}})
-- ({{1,0}}|-{{axis description cs:1,0}});
\end{axis}
\end{tikzpicture}
\end{document}


• This is close to the graph that I want. Here is one feature to modify. I would like both the y-axis and the vertical line x=1 to be lengthened upwards and downwards a bit, but I want the y-axis to be distinctly longer. (The graph is too close to the top arrowhead in line x=1.) Here are 3 features to add. "y" is to be typeset to the right and above the top arrowhead on the y-axis, and "x" is to be typeset to the right and below the right arrowhead on the x-axis. I would like the horizontal asymptote y=1 to be drawn, again wider than the graph of the function and shorter than the x-axis. – user60254 Sep 25 '14 at 12:36
• I forgot about two features. I would like \draw [fill=white] (-3,0.25) circle [radius=1.5pt] node[left]{}; added to the code. You have the tick mark -2 in a smaller font. (Why doesn't my code typeset it in the same small font?) I would like these coordinates in the same font. – user60254 Sep 25 '14 at 12:51
• The label "x=1" is to be typeset on the vertical asymptote. Preferably, it would be typeset towards the bottom arrowhead, going upwards. I think the code is something like node[fill=white,sloped] {$x=1$}. – user60254 Sep 25 '14 at 13:03

Answering your question about the axis label placement: You can basically do what Christian Feuersänger did in his answer to How can I adjust the position of xlabel and ylabel with pgfplots?, with a minor adjustment. If you set

xlabel style={at={(ticklabel* cs:1)}, anchor=north west}
ylabel style={at={(ticklabel* cs:1)}, anchor=south west}


the labels will be placed as desired. The key at={(ticklabel* cs:1)} instructs PGFPlots to place the label node at the tip of the axis line. The key anchor=north west instructs PGFPlots not to center the label node on the tip of the axis line, but instead to place the upper left corner (i.e. the "north west" corner) on the tip of the axis line.

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle, enlargelimits,
xlabel=$x$, ylabel=$y$,
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
]


• With other labels, there is a node command - like node[left,pos=0.25]{$y=f(x)$} - that instructs PGFPlots of the positions to place them. Is this another node command? What does the syntax at={} within the style command conveying to PGFPlots? – user60254 Sep 28 '14 at 12:56
• @user60254: The x and y labels are created using nodes internally. The position, alignment and appearance of these nodes is determined using styles, which are influenced by setting xlabel style and ylabel style. The at={<coordinate>} syntax tells PGFPlots where to put the labels. For example, the expressions \node at (2,4) {text};, \path (2,4) node {text}; and \node [at={(2,4)}] {text}; are all equivalent. – Jake Sep 28 '14 at 17:26