# Plot asymptote on graph

**URL:** <https://community.wolfram.com/t/plot-asymptote-on-graph/17584>\
**Category:** Questions\
**Tags:** graphics-and-visualization\
**Created:** [February 8, 2021, 1:03pm UTC](https://community.wolfram.com/t/plot-asymptote-on-graph/17584 "2021-02-08T13:03:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tetyushins](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@tetyushins](https://community.wolfram.com/u/tetyushins)\
**Post date:** [February 8, 2021, 1:03pm UTC](https://community.wolfram.com/t/plot-asymptote-on-graph/17584/1 "2021-02-08T13:03:24Z")

</div>

Is it possible to plot an asymptote via a command? I have a function, I plotted it, but there is a problem with the asymptotes, how to plot them? I did a search but it was not unsuccessful. 1 screenshot is how my graph should look like, and 2 screenshot is where I am now

 ![Снимокэкрана2021-02-08в16.01.47.png](https://global.discourse-cdn.com/wolfram/original/3X/5/5/555ae39effe9200bc074bc07ddfb11d3a55b0d0b.png)

```
Plot[{(2 x^2 - 9)/Sqrt[x^2 - 1]}, {x, -13, 13}, AxesLabel -> {X, Y}, 
 GridLines -> {{1}, None}]

```

 ![Снимокэкрана2021-02-08в16.02.13.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/e/6ef88e265e7c6ba6f31b9a4294c5cb309a693334.jpeg)

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [February 8, 2021, 3:18pm UTC](https://community.wolfram.com/t/plot-asymptote-on-graph/17584/2 "2021-02-08T15:18:27Z")

</div>

Hi Semen

```
exp = (2 x^2 - 9)/Sqrt[x^2 - 1];

asymptotes = ResourceFunction["Asymptotes"][exp, x, y]
(* <|"Vertical" -> {{y -> -∞, x -> ±1}}, 
     "Oblique" -> {{y -> -2 x, x -> -∞}, {y -> 2 x, x -> ∞}}|> *)

```

If you have to do this for many plots, I would write some code to generate line endpoints from `asymptotes`. Here I just did it manually

```
epilog = {Dashed, Darker[Green], InfiniteLine[{{-1, -1}, {-1, 1}}], 
  InfiniteLine[{{1, -1}, {1, 1}}], Red, InfiniteLine[{{-1, -2}, {0, 0}}]}

Plot[exp, {x, -13, 13}, AxesLabel -> {"X", "Y"}, Epilog -> epilog]

```

 ![2589plot.png](https://global.discourse-cdn.com/wolfram/original/3X/8/5/8557f35efd6d53f6345e69a323b7c60b61acb57f.png)

---

<div class="post-metadata">

**Author:** ![tetyushins](https://avatars.discourse-cdn.com/v4/letter/t/71c47a/32.png) [@tetyushins](https://community.wolfram.com/u/tetyushins)\
**Post date:** [February 8, 2021, 4:16pm UTC](https://community.wolfram.com/t/plot-asymptote-on-graph/17584/3 "2021-02-08T16:16:39Z")

</div>

Thanks for the help, I’m new to this and found little information for the graphs. I thought there was a special team that draws everything at once.

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [February 8, 2021, 5:07pm UTC](https://community.wolfram.com/t/plot-asymptote-on-graph/17584/4 "2021-02-08T17:07:48Z")

</div>

You could ask the developer to provide the functionality directly. Here is an attempt to do it automatically:

```
exp = (2 x^2 - 9)/Sqrt[x^2 - 1];
{asymptotesObl, asymptotesVert, asymptotesHor} =
  Table[ResourceFunction["Asymptotes"][exp, x, y, type],
   {type, {"Oblique", "Vertical", "Horizontal"}}];
asymptotesPrimitives = {If[asymptotesObl == {}, Nothing, 
    InfiniteLine[{0, 0}, {x, y}] /. asymptotesObl[[All, {1}]] /. 
     x -> 1],
   If[asymptotesVert == {}, Nothing,
    InfiniteLine[{x, 0}, {0, 
       1}] /.
     (asymptotesVert[[All, {2}]] /.
       {x -> \
\[PlusMinus]val_} :>
        Splice[{{x -> -val}, {x -> val}}])],
   If[asymptotesHor == {}, Nothing,
    InfiniteLine[{0, y}, {1, 0}] /. asymptotesHor]};
Plot[exp, {x, -13, 13}, Epilog -> {asymptotesPrimitives}]

```

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [February 8, 2021, 10:22pm UTC](https://community.wolfram.com/t/plot-asymptote-on-graph/17584/5 "2021-02-08T22:22:42Z")

</div>

Hi, here is another - short and simple - approach:

```
func = (2 x^2 - 9)/Sqrt[x^2 - 1];
asympt = Asymptotic[func, x -> Infinity];
Plot[{func, asympt}, {x, -13, 13}, AxesLabel -> {"X", "Y"}, GridLines -> {{1}, None}, PlotStyle -> {Automatic, Dashed}]

```

 ![asympt.png](https://global.discourse-cdn.com/wolfram/original/3X/1/0/108f8507d6b5669aaa0d67a974b19041dcf30403.png)
