# Adding limits to the Y-axis for SymPy.jl plots

**URL:** <https://discourse.julialang.org/t/adding-limits-to-the-y-axis-for-sympy-jl-plots/29571>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [October 7, 2019, 6:34am UTC](https://discourse.julialang.org/t/adding-limits-to-the-y-axis-for-sympy-jl-plots/29571 "2019-10-07T06:34:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![00krishna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00krishna/32/8843_2.png) [@00krishna](https://discourse.julialang.org/u/00krishna)\
**Post date:** [October 7, 2019, 6:34am UTC](https://discourse.julialang.org/t/adding-limits-to-the-y-axis-for-sympy-jl-plots/29571/1 "2019-10-07T06:34:14Z")

</div>

I was using SymPy.jl to plot the phase flow of some simple dynamical systems. But I ran into an issue when plotting a particular equation with some discontinuities.

\dot{\theta} = \frac{\sin{\theta}}{\mu + \sin{\theta}}

This plot has a few points, depending on the \mu parameter, where the derivative of \theta collapses to infinity. But when the plot experiences discontinuities, the Y-axis gets so big that it hides the features of the plot along the X-axis. I included an example picture just for demonstration.

The code was  
`plot(sin(x)/(-1+sin(x)), 0, 4)`

 ![Selection_010](https://global.discourse-cdn.com/julialang/original/3X/5/9/599d42961e862e3be4a16909e3b2128dc7c9e1bc.png)

Hence I was wondering if there is a way to set the limits of the Y-axis to some smaller range? I could not find any examples of this in the SymPy tutorials so figured I would ask. Thanks.

---

<div class="post-metadata">

**Author:** ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Post date:** [October 7, 2019, 10:14am UTC](https://discourse.julialang.org/t/adding-limits-to-the-y-axis-for-sympy-jl-plots/29571/2 "2019-10-07T10:14:47Z")

</div>

It is the same solution as when using Plots. Maybe explicitly setting ylim values, or trimming your output with a function that uses NaN when the y values are large, or adjusting your domain will work for you

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [October 7, 2019, 10:36am UTC](https://discourse.julialang.org/t/adding-limits-to-the-y-axis-for-sympy-jl-plots/29571/3 "2019-10-07T10:36:28Z")

</div>

I assume you are using PyPlot.jl, i.e. matplotlib, for plotting. In this case you can use `ylim(ymin, ymax)` to set the limits of the y-axes to `ymin` and `ymax` respectively.

---

<div class="post-metadata">

**Author:** ![00krishna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00krishna/32/8843_2.png) [@00krishna](https://discourse.julialang.org/u/00krishna)\
**Post date:** [October 8, 2019, 12:56am UTC](https://discourse.julialang.org/t/adding-limits-to-the-y-axis-for-sympy-jl-plots/29571/4 "2019-10-08T00:56:50Z")

</div>

Oh great. Thanks for pointing this out. I did not realize that SymPy was accessing the regular Plots api. I kept thinking that the plots were based on some internal implementation of the `plot()` function. Thanks so much.

---

<div class="post-metadata">

**Author:** ![00krishna](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00krishna/32/8843_2.png) [@00krishna](https://discourse.julialang.org/u/00krishna)\
**Post date:** [October 8, 2019, 1:09am UTC](https://discourse.julialang.org/t/adding-limits-to-the-y-axis-for-sympy-jl-plots/29571/5 "2019-10-08T01:09:31Z")

</div>

@j_verzani thanks again for your help. I am finally getting up to speed on SymPy, so hopefully I won’t keep pestering you with these types of questions. But thanks again for being so patient with me.
