ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 25 Aug 2020 15:18:30 +0200Plotting multiple functions with different growth rateshttps://ask.sagemath.org/question/53169/plotting-multiple-functions-with-different-growth-rates/Hi, I'm new to sagemath. I wanted to plot two different functions with different growth rates. For example, 1/x and x. I used the following code snippet. Because 1/x goes to infinity at 0, the other function can not be distinguished from the 1/x function in the plot. How can I limit plotting to specific range for example, plot only y from 0 to 10 and from 0 to 10 ?
f1 = plot((x), (x,0,2))
f2 = plot((1/x), (x,0,2))
show(f1+f2)Tue, 25 Aug 2020 14:39:04 +0200https://ask.sagemath.org/question/53169/plotting-multiple-functions-with-different-growth-rates/Answer by slelievre for <p>Hi, I'm new to sagemath. I wanted to plot two different functions with different growth rates. For example, 1/x and x. I used the following code snippet. Because 1/x goes to infinity at 0, the other function can not be distinguished from the 1/x function in the plot. How can I limit plotting to specific range for example, plot only y from 0 to 10 and from 0 to 10 ?</p>
<pre><code>f1 = plot((x), (x,0,2))
f2 = plot((1/x), (x,0,2))
show(f1+f2)
</code></pre>
https://ask.sagemath.org/question/53169/plotting-multiple-functions-with-different-growth-rates/?answer=53171#post-id-53171Use the `ymin` and `ymax` keywords.
sage: f1 = plot((x), (x, 0, 2))
sage: f2 = plot((1/x), (x, 0, 2))
sage: p = f1 + f2
sage: p.show(ymin=0, ymax=10)Tue, 25 Aug 2020 15:18:30 +0200https://ask.sagemath.org/question/53169/plotting-multiple-functions-with-different-growth-rates/?answer=53171#post-id-53171