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, 31 Mar 2020 16:08:59 +0200range() function in list_plot not working?https://ask.sagemath.org/question/50435/range-function-in-list_plot-not-working/I'm trying to generate a list plot of points that satisfy the relation { (x,2x) | x = 0,+-1, +-2 }.
That is, 5 discrete integer values of x ranging from -2 to +2 that satisfy the equation y = 2x.
I figured my solution...show(list_plot([x*2 for x in range(-2,3)]), figsize=3) should have worked;
however, the resulting plot ends up shifted to the incorrect domain. I can't upload the image because my
karma is too low, but the resulting plot fits the function y = 2(x - 2). It gives the correct range of y values,
from -4 to 4, but the domain is from 0 to 4.
Anybody know what I'm missing? Thanks!Mon, 30 Mar 2020 07:05:55 +0200https://ask.sagemath.org/question/50435/range-function-in-list_plot-not-working/Answer by Juanjo for <p>I'm trying to generate a list plot of points that satisfy the relation { (x,2x) | x = 0,+-1, +-2 }.
That is, 5 discrete integer values of x ranging from -2 to +2 that satisfy the equation y = 2x.</p>
<p>I figured my solution...show(list_plot([x*2 for x in range(-2,3)]), figsize=3) should have worked;
however, the resulting plot ends up shifted to the incorrect domain. I can't upload the image because my
karma is too low, but the resulting plot fits the function y = 2(x - 2). It gives the correct range of y values,
from -4 to 4, but the domain is from 0 to 4. </p>
<p>Anybody know what I'm missing? Thanks!</p>
https://ask.sagemath.org/question/50435/range-function-in-list_plot-not-working/?answer=50444#post-id-50444Try
show(list_plot([(x,x*2) for x in range(-2,3)]), figsize=3)
If you don't specify the abcissae, it is assumed that they are 0, 1, 2, 3...Tue, 31 Mar 2020 16:08:59 +0200https://ask.sagemath.org/question/50435/range-function-in-list_plot-not-working/?answer=50444#post-id-50444