ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 17 Dec 2011 15:31:49 -0600how to correctly plot 1/(x-3)https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/I have to plot 1/(x-3). clearly the function is not defined at x=3. Whenever I try to plot it there is a huge vertical line at x=3, which should not be there. Help me out.
The code I write
sage: f(x)=1/(x-3)
sage: p=plot(f(x),(x,-10,10)
sage: p.show()
Thanks
AmitThu, 15 Dec 2011 22:12:52 -0600https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/Answer by Amit Kumar for <p>I have to plot 1/(x-3). clearly the function is not defined at x=3. Whenever I try to plot it there is a huge vertical line at x=3, which should not be there. Help me out.</p>
<p>The code I write
sage: f(x)=1/(x-3)
sage: p=plot(f(x),(x,-10,10)
sage: p.show()</p>
<p>Thanks
Amit</p>
https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?answer=13034#post-id-13034Thanks Jason,tririver and Niles for the help.
especially Jason... Your method is with the least code and effective.
Thanks Fri, 16 Dec 2011 21:27:29 -0600https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?answer=13034#post-id-13034Comment by niles for <p>Thanks Jason,tririver and Niles for the help.</p>
<p>especially Jason... Your method is with the least code and effective.
Thanks </p>
https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?comment=20694#post-id-20694You're welcome :) If you want, you can click the check mark to "accept" Jason's answer.Sat, 17 Dec 2011 15:31:49 -0600https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?comment=20694#post-id-20694Answer by niles for <p>I have to plot 1/(x-3). clearly the function is not defined at x=3. Whenever I try to plot it there is a huge vertical line at x=3, which should not be there. Help me out.</p>
<p>The code I write
sage: f(x)=1/(x-3)
sage: p=plot(f(x),(x,-10,10)
sage: p.show()</p>
<p>Thanks
Amit</p>
https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?answer=13020#post-id-13020In Sage you can add separate plots to draw them on the same image; try this:
sage: f(x)=1/(x-3)
sage: p=plot(f(x),(x,-10,2.9), aspect_ratio=1)
sage: q=plot(f(x),(x,3.1,10), aspect_ratio=1)
sage: (p+q).show()
or, if you want to be a little fancy, add the asymptote:
sage: L = line2d([(3,10),(3,-10)], linestyle="dashed", color="red")
sage: (p+q+L).show()
Thu, 15 Dec 2011 23:39:37 -0600https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?answer=13020#post-id-13020Answer by Jason Grout for <p>I have to plot 1/(x-3). clearly the function is not defined at x=3. Whenever I try to plot it there is a huge vertical line at x=3, which should not be there. Help me out.</p>
<p>The code I write
sage: f(x)=1/(x-3)
sage: p=plot(f(x),(x,-10,10)
sage: p.show()</p>
<p>Thanks
Amit</p>
https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?answer=13028#post-id-13028You can also use the [detect_poles](http://www.sagemath.org/doc/reference/sage/plot/plot.html#sage.plot.plot.plot) option to not draw the vertical line
plot(1/(x-3),(x,0,5), detect_poles=True,ymin=-2,ymax=2)
Or even better, have it automatically draw the asymptote:
plot(1/(x-3),(x,0,5), detect_poles='show',ymin=-2,ymax=2)
Fri, 16 Dec 2011 02:44:41 -0600https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?answer=13028#post-id-13028Answer by tririver for <p>I have to plot 1/(x-3). clearly the function is not defined at x=3. Whenever I try to plot it there is a huge vertical line at x=3, which should not be there. Help me out.</p>
<p>The code I write
sage: f(x)=1/(x-3)
sage: p=plot(f(x),(x,-10,10)
sage: p.show()</p>
<p>Thanks
Amit</p>
https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?answer=13021#post-id-13021Use a plot range in show
p.show(ymin=-2, ymax=2)Thu, 15 Dec 2011 23:45:38 -0600https://ask.sagemath.org/question/8563/how-to-correctly-plot-1x-3/?answer=13021#post-id-13021