Plotting Functions with Asymptotes


We will be plotting a function with vertical asymptotes using multiple plotting functions. Due to the nature of the way Sage generates graphs, not using these options will likely result in a graph with an enormous range and inaccurate function values near the asymptotes. Specifically, we will be setting ymin, ymax, and detect_poles.

Sage Cell

Setting ymin and ymax prevents Sage from plotting on a range in the thousands, while setting detect_poles=True prevents Sage from mistakenly graphing on the asymptote (for this example, had we not set detect_poles=True we would have seen a line on $-2$ and $2$).


plot(1/(x^3 -x ), -2, 2, ymin=-5, ymax=5, detect_poles=True)



Showing the asymptotes with a dashed line. Simply set select_poles='show'. Note the single quotes around 'show' because show is not a Sage keyword.


plot(1/(x^3 -x ), -2, 2, ymin=-5, ymax=5, detect_poles='show')


Primary Tags: Plotting: Two-dimensional plots

Secondary Tags: Two-dimensional plots: Rectangular plots

Related Cells



Author: Gregory V. Bard. Sage for Undergraduates. American Mathematical Society, Providence, RI, 2015. Available at

Date: 15 Feb 2019 01:20

Submitted by: Zane Corbiere

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License