TeX - LaTeX Asked by Ananaskirsche on December 14, 2020
I would like to plot the following expression: (x-1)/(x+2)
However if I add this in pgfplot as an expression, I get this result:
I would like to make the part in the middle disappear, since the function jumps at x=-2. It should look like this:
How can I achieve this? Currently I am using the following code:
begin{tikzpicture}
begin{axis}[
grid,
xlabel={$x$},
ylabel={$y$},
legend entries={$frac{1-x}{x+2}$},
legend style={at={(0.17, 1)}, anchor=north},
every axis plot/.append style={thick}
]
addplot [mark=none, blue, samples=1000, unbounded coords = jump] expression {(x-1)/(x+2)};
end{axis}
end{tikzpicture}
I have already tried splitting the function in two domains, but this does not work somehow.
Restricting the y axes did the trick for me:
begin{tikzpicture}
begin{axis}[
grid,
xlabel={$x$},
ylabel={$y$},
legend entries={$frac{1-x}{x+2}$},
every axis plot/.append style={thick},
restrict y to domain=-500:500
]
addplot [mark=none, blue, samples=1000] expression {(x-1)/(x+2)};
end{axis}
end{tikzpicture}
Answered by Ananaskirsche on December 14, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP