How can I plot vertical asymptote in my graph?












2















I'm trying to plot vertical asymptotes in my graph but I can't.



This is my code:



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}









share|improve this question























  • Possibly duplicate: tex.stackexchange.com/a/34201/31034

    – ferahfeza
    Mar 24 at 9:38











  • I'm trying to understand why this 2 line " draw[dashed] ( -3,-8) -- ( -3,+8); draw[dashed] ( 3,-8) -- ( 3,+8);" aren't working

    – ryuk
    Mar 24 at 9:41











  • Use axis cs for coordinate definition in draw. draw[dashed] ( axis cs:-3,-8) -- (axis cs: -3,+8);

    – ferahfeza
    Mar 24 at 10:34











  • I suggest a tikz-only solution. That's simpler!

    – Black Mild
    Mar 24 at 16:36
















2















I'm trying to plot vertical asymptotes in my graph but I can't.



This is my code:



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}









share|improve this question























  • Possibly duplicate: tex.stackexchange.com/a/34201/31034

    – ferahfeza
    Mar 24 at 9:38











  • I'm trying to understand why this 2 line " draw[dashed] ( -3,-8) -- ( -3,+8); draw[dashed] ( 3,-8) -- ( 3,+8);" aren't working

    – ryuk
    Mar 24 at 9:41











  • Use axis cs for coordinate definition in draw. draw[dashed] ( axis cs:-3,-8) -- (axis cs: -3,+8);

    – ferahfeza
    Mar 24 at 10:34











  • I suggest a tikz-only solution. That's simpler!

    – Black Mild
    Mar 24 at 16:36














2












2








2








I'm trying to plot vertical asymptotes in my graph but I can't.



This is my code:



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}









share|improve this question














I'm trying to plot vertical asymptotes in my graph but I can't.



This is my code:



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}






tikz-pgf pgfplots






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 9:19









ryukryuk

1,124722




1,124722













  • Possibly duplicate: tex.stackexchange.com/a/34201/31034

    – ferahfeza
    Mar 24 at 9:38











  • I'm trying to understand why this 2 line " draw[dashed] ( -3,-8) -- ( -3,+8); draw[dashed] ( 3,-8) -- ( 3,+8);" aren't working

    – ryuk
    Mar 24 at 9:41











  • Use axis cs for coordinate definition in draw. draw[dashed] ( axis cs:-3,-8) -- (axis cs: -3,+8);

    – ferahfeza
    Mar 24 at 10:34











  • I suggest a tikz-only solution. That's simpler!

    – Black Mild
    Mar 24 at 16:36



















  • Possibly duplicate: tex.stackexchange.com/a/34201/31034

    – ferahfeza
    Mar 24 at 9:38











  • I'm trying to understand why this 2 line " draw[dashed] ( -3,-8) -- ( -3,+8); draw[dashed] ( 3,-8) -- ( 3,+8);" aren't working

    – ryuk
    Mar 24 at 9:41











  • Use axis cs for coordinate definition in draw. draw[dashed] ( axis cs:-3,-8) -- (axis cs: -3,+8);

    – ferahfeza
    Mar 24 at 10:34











  • I suggest a tikz-only solution. That's simpler!

    – Black Mild
    Mar 24 at 16:36

















Possibly duplicate: tex.stackexchange.com/a/34201/31034

– ferahfeza
Mar 24 at 9:38





Possibly duplicate: tex.stackexchange.com/a/34201/31034

– ferahfeza
Mar 24 at 9:38













I'm trying to understand why this 2 line " draw[dashed] ( -3,-8) -- ( -3,+8); draw[dashed] ( 3,-8) -- ( 3,+8);" aren't working

– ryuk
Mar 24 at 9:41





I'm trying to understand why this 2 line " draw[dashed] ( -3,-8) -- ( -3,+8); draw[dashed] ( 3,-8) -- ( 3,+8);" aren't working

– ryuk
Mar 24 at 9:41













Use axis cs for coordinate definition in draw. draw[dashed] ( axis cs:-3,-8) -- (axis cs: -3,+8);

– ferahfeza
Mar 24 at 10:34





Use axis cs for coordinate definition in draw. draw[dashed] ( axis cs:-3,-8) -- (axis cs: -3,+8);

– ferahfeza
Mar 24 at 10:34













I suggest a tikz-only solution. That's simpler!

– Black Mild
Mar 24 at 16:36





I suggest a tikz-only solution. That's simpler!

– Black Mild
Mar 24 at 16:36










1 Answer
1






active

oldest

votes


















5














The issue is that you do not specify the compatibility version, so pgfplots runs in backwards mode. If you want to keep that, you need to add axis cs: to the coordinates in the draw mode. It is arguably simpler and better to specify a reasonably new version.



documentclass[a4paper]{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


enter image description here



If you need to run pgfplots in backwards compatibility mode, you could use



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8);
draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


which yields the same output. However, I would like to argue it is better to update the TeX installation because, apart from adding features, some real bugs have been fixed.






share|improve this answer


























  • when i try to compile your code, there is an error "! Package pgfkeys Error: Choice '1.16' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key.". Why? maybe "pgfplotsset{compat=1.16}"?

    – ryuk
    Mar 24 at 17:45








  • 2





    @ryuk 1.16 is the current version. This error message means that you haven't updated your TeX installation in a while. So you could (i) update your TeX installation or (ii) try with a lower version (1.15, 1.14 ...) or (iii) drop pgfplotsset{compat=1.16} and use draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8); draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);.

    – marmot
    Mar 24 at 17:48













  • Thanks! I would linke in the point (11, 4) the write $y=f(x)$. Could you help me?

    – ryuk
    Mar 24 at 18:07






  • 1





    @ryuk node at (11,4) {$y=f(x)$}; or node at (axis cs:11,4) {$y=f(x)$}; Notice that there is also the possibility to add a legend, this site is full of examples.

    – marmot
    Mar 24 at 18:08








  • 1





    @ryuk Yes, because you have tick label style={font=tiny},, so the other labels have font size tiny, so you may want to try path (axis cs:0,0) node[below right,font=tiny] {$0$};.

    – marmot
    Mar 25 at 14:41














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481171%2fhow-can-i-plot-vertical-asymptote-in-my-graph%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














The issue is that you do not specify the compatibility version, so pgfplots runs in backwards mode. If you want to keep that, you need to add axis cs: to the coordinates in the draw mode. It is arguably simpler and better to specify a reasonably new version.



documentclass[a4paper]{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


enter image description here



If you need to run pgfplots in backwards compatibility mode, you could use



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8);
draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


which yields the same output. However, I would like to argue it is better to update the TeX installation because, apart from adding features, some real bugs have been fixed.






share|improve this answer


























  • when i try to compile your code, there is an error "! Package pgfkeys Error: Choice '1.16' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key.". Why? maybe "pgfplotsset{compat=1.16}"?

    – ryuk
    Mar 24 at 17:45








  • 2





    @ryuk 1.16 is the current version. This error message means that you haven't updated your TeX installation in a while. So you could (i) update your TeX installation or (ii) try with a lower version (1.15, 1.14 ...) or (iii) drop pgfplotsset{compat=1.16} and use draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8); draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);.

    – marmot
    Mar 24 at 17:48













  • Thanks! I would linke in the point (11, 4) the write $y=f(x)$. Could you help me?

    – ryuk
    Mar 24 at 18:07






  • 1





    @ryuk node at (11,4) {$y=f(x)$}; or node at (axis cs:11,4) {$y=f(x)$}; Notice that there is also the possibility to add a legend, this site is full of examples.

    – marmot
    Mar 24 at 18:08








  • 1





    @ryuk Yes, because you have tick label style={font=tiny},, so the other labels have font size tiny, so you may want to try path (axis cs:0,0) node[below right,font=tiny] {$0$};.

    – marmot
    Mar 25 at 14:41


















5














The issue is that you do not specify the compatibility version, so pgfplots runs in backwards mode. If you want to keep that, you need to add axis cs: to the coordinates in the draw mode. It is arguably simpler and better to specify a reasonably new version.



documentclass[a4paper]{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


enter image description here



If you need to run pgfplots in backwards compatibility mode, you could use



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8);
draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


which yields the same output. However, I would like to argue it is better to update the TeX installation because, apart from adding features, some real bugs have been fixed.






share|improve this answer


























  • when i try to compile your code, there is an error "! Package pgfkeys Error: Choice '1.16' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key.". Why? maybe "pgfplotsset{compat=1.16}"?

    – ryuk
    Mar 24 at 17:45








  • 2





    @ryuk 1.16 is the current version. This error message means that you haven't updated your TeX installation in a while. So you could (i) update your TeX installation or (ii) try with a lower version (1.15, 1.14 ...) or (iii) drop pgfplotsset{compat=1.16} and use draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8); draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);.

    – marmot
    Mar 24 at 17:48













  • Thanks! I would linke in the point (11, 4) the write $y=f(x)$. Could you help me?

    – ryuk
    Mar 24 at 18:07






  • 1





    @ryuk node at (11,4) {$y=f(x)$}; or node at (axis cs:11,4) {$y=f(x)$}; Notice that there is also the possibility to add a legend, this site is full of examples.

    – marmot
    Mar 24 at 18:08








  • 1





    @ryuk Yes, because you have tick label style={font=tiny},, so the other labels have font size tiny, so you may want to try path (axis cs:0,0) node[below right,font=tiny] {$0$};.

    – marmot
    Mar 25 at 14:41
















5












5








5







The issue is that you do not specify the compatibility version, so pgfplots runs in backwards mode. If you want to keep that, you need to add axis cs: to the coordinates in the draw mode. It is arguably simpler and better to specify a reasonably new version.



documentclass[a4paper]{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


enter image description here



If you need to run pgfplots in backwards compatibility mode, you could use



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8);
draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


which yields the same output. However, I would like to argue it is better to update the TeX installation because, apart from adding features, some real bugs have been fixed.






share|improve this answer















The issue is that you do not specify the compatibility version, so pgfplots runs in backwards mode. If you want to keep that, you need to add axis cs: to the coordinates in the draw mode. It is arguably simpler and better to specify a reasonably new version.



documentclass[a4paper]{article}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] ( -3,-8) -- ( -3,+8);
draw[dashed] ( 3,-8) -- ( 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


enter image description here



If you need to run pgfplots in backwards compatibility mode, you could use



documentclass[a4paper]{article}
usepackage{pgfplots}
usepackage{amsmath}
begin{document}
begin{center}
begin{tikzpicture}
begin{axis}%
[
grid=major,
x=5mm,
y=5mm,
xtick={-15,-14,...,15},
xmin=-15,
xmax=15,
xlabel={tiny $x$},
axis x line=middle,
ytick={-8,-7,...,8},
tick label style={font=tiny},
ymin=-8,
ymax=8,
ylabel={scriptsize $ qquad qquad qquad f(x)=dfrac{x^2-4*x-5}{x^2-9}$},
axis y line=middle,
no markers,
samples=100,
domain=-15:15,
restrict y to domain=-10:10
]
addplot[thick,samples=800] (x,{(x^2-4*x-5)/(x^2-9});
addplot[thick,dashed, samples=800] (x,1);
draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8);
draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);
end{axis}
end{tikzpicture}
end{center}
end{document}


which yields the same output. However, I would like to argue it is better to update the TeX installation because, apart from adding features, some real bugs have been fixed.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 24 at 17:52

























answered Mar 24 at 13:16









marmotmarmot

114k5145276




114k5145276













  • when i try to compile your code, there is an error "! Package pgfkeys Error: Choice '1.16' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key.". Why? maybe "pgfplotsset{compat=1.16}"?

    – ryuk
    Mar 24 at 17:45








  • 2





    @ryuk 1.16 is the current version. This error message means that you haven't updated your TeX installation in a while. So you could (i) update your TeX installation or (ii) try with a lower version (1.15, 1.14 ...) or (iii) drop pgfplotsset{compat=1.16} and use draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8); draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);.

    – marmot
    Mar 24 at 17:48













  • Thanks! I would linke in the point (11, 4) the write $y=f(x)$. Could you help me?

    – ryuk
    Mar 24 at 18:07






  • 1





    @ryuk node at (11,4) {$y=f(x)$}; or node at (axis cs:11,4) {$y=f(x)$}; Notice that there is also the possibility to add a legend, this site is full of examples.

    – marmot
    Mar 24 at 18:08








  • 1





    @ryuk Yes, because you have tick label style={font=tiny},, so the other labels have font size tiny, so you may want to try path (axis cs:0,0) node[below right,font=tiny] {$0$};.

    – marmot
    Mar 25 at 14:41





















  • when i try to compile your code, there is an error "! Package pgfkeys Error: Choice '1.16' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key.". Why? maybe "pgfplotsset{compat=1.16}"?

    – ryuk
    Mar 24 at 17:45








  • 2





    @ryuk 1.16 is the current version. This error message means that you haven't updated your TeX installation in a while. So you could (i) update your TeX installation or (ii) try with a lower version (1.15, 1.14 ...) or (iii) drop pgfplotsset{compat=1.16} and use draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8); draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);.

    – marmot
    Mar 24 at 17:48













  • Thanks! I would linke in the point (11, 4) the write $y=f(x)$. Could you help me?

    – ryuk
    Mar 24 at 18:07






  • 1





    @ryuk node at (11,4) {$y=f(x)$}; or node at (axis cs:11,4) {$y=f(x)$}; Notice that there is also the possibility to add a legend, this site is full of examples.

    – marmot
    Mar 24 at 18:08








  • 1





    @ryuk Yes, because you have tick label style={font=tiny},, so the other labels have font size tiny, so you may want to try path (axis cs:0,0) node[below right,font=tiny] {$0$};.

    – marmot
    Mar 25 at 14:41



















when i try to compile your code, there is an error "! Package pgfkeys Error: Choice '1.16' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key.". Why? maybe "pgfplotsset{compat=1.16}"?

– ryuk
Mar 24 at 17:45







when i try to compile your code, there is an error "! Package pgfkeys Error: Choice '1.16' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key.". Why? maybe "pgfplotsset{compat=1.16}"?

– ryuk
Mar 24 at 17:45






2




2





@ryuk 1.16 is the current version. This error message means that you haven't updated your TeX installation in a while. So you could (i) update your TeX installation or (ii) try with a lower version (1.15, 1.14 ...) or (iii) drop pgfplotsset{compat=1.16} and use draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8); draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);.

– marmot
Mar 24 at 17:48







@ryuk 1.16 is the current version. This error message means that you haven't updated your TeX installation in a while. So you could (i) update your TeX installation or (ii) try with a lower version (1.15, 1.14 ...) or (iii) drop pgfplotsset{compat=1.16} and use draw[dashed] (axis cs: -3,-8) -- (axis cs: -3,+8); draw[dashed] (axis cs: 3,-8) -- (axis cs: 3,+8);.

– marmot
Mar 24 at 17:48















Thanks! I would linke in the point (11, 4) the write $y=f(x)$. Could you help me?

– ryuk
Mar 24 at 18:07





Thanks! I would linke in the point (11, 4) the write $y=f(x)$. Could you help me?

– ryuk
Mar 24 at 18:07




1




1





@ryuk node at (11,4) {$y=f(x)$}; or node at (axis cs:11,4) {$y=f(x)$}; Notice that there is also the possibility to add a legend, this site is full of examples.

– marmot
Mar 24 at 18:08







@ryuk node at (11,4) {$y=f(x)$}; or node at (axis cs:11,4) {$y=f(x)$}; Notice that there is also the possibility to add a legend, this site is full of examples.

– marmot
Mar 24 at 18:08






1




1





@ryuk Yes, because you have tick label style={font=tiny},, so the other labels have font size tiny, so you may want to try path (axis cs:0,0) node[below right,font=tiny] {$0$};.

– marmot
Mar 25 at 14:41







@ryuk Yes, because you have tick label style={font=tiny},, so the other labels have font size tiny, so you may want to try path (axis cs:0,0) node[below right,font=tiny] {$0$};.

– marmot
Mar 25 at 14:41




















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f481171%2fhow-can-i-plot-vertical-asymptote-in-my-graph%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?