I would like the code that instructs TikZ to plot the graph for the rational function y=(x^{2}+5x+6)/(x^{2}+2x-3)
. I tried using addplot[very thin,blue]{frac(x^{2}+5x+6)/(x^{2}+2x-3)}
. This graph has a vertical asymptote x = 1. What is the code for plotting this line – as a dashed line – with arrowheads?
\documentclass[10pt]{amsart}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\begin{document}
\hspace*{\fill}
\begin{tikzpicture}
\begin{axis}[axis equal image,
xmax=8,ymax=7,
axis lines=middle,
restrict y to domain=-7:7,
enlargelimits={abs=1cm},
axis line style={latex-latex},
ticklabel style={fill=white},
ytick=\empty,
xtick={-3}
%xlabel=$x$,ylabel=$y$,
]
\addplot[domain=-10:10,mark=none,samples=10] {frac{x + 2}{x - 1} node [above left, yshift=3pt]{$\scriptstyle{y}=\frac{x^{2}+5x+6}{x^{2}+2x-3}$};
\draw [fill=white] (-3,0) circle [radius=1.5pt];
\end{axis}
\end{tikzpicture}
\hspace{\fill}
\end{document}
Best Answer
With my version of PGFplots, the
\addplot
command you provide doesn't even compile, so I had to guess what you want to achieve. In PGFplots you can just write fractions like this:1/(x^2)
.With Matthew's comment to Jake's answer to this question you can drawn an asymptote at
x=1
by using the keyvasymptote=1
. In order to reliably truncate the plot without using many samples (orange curve), you can plot the two parts separately, specifying thedomain
so that is ends slightly beforex=1
(black curve).