1 | initial version |
To complement @dazedANDconfused answer, which is correct, you can first notice that you do not need to write arrays if you only want to plot the function, you can simply do:
sage: m = 5
sage: r = 3
sage: w = 6
sage: f(t) = m*r*w^2*cos(t*pi/180)
sage: plot(f, t, 0, 360)
Second, you can use the Python zip function to avoid iterating among indexes 0
...len(x_coords)-1
by hand:
sage: list_plot(zip(x_coords,y_coords))
The following also works:
sage: points(zip(x_coords,y_coords))
2 | No.2 Revision |
To complement @dazedANDconfused answer, which is correct, you can first notice that you do not need to write arrays if you only want to plot the function, you can simply do:
sage: m = 5
sage: r = 3
sage: w = 6
sage: f(t) = m*r*w^2*cos(t*pi/180)
sage: plot(f, t, 0, 360)
Second, if you want to deal with X and Y arrays (lists), you can use the Python zip function to avoid iterating among indexes 0
...len(x_coords)-1
by hand:
sage: zip([1,2,3],[4,5,6])
[(1, 4), (2, 5), (3, 6)]
So in your case, you can write the less verbose:
sage: list_plot(zip(x_coords,y_coords))
The following also works:
sage: points(zip(x_coords,y_coords))
3 | No.3 Revision |
To complement @dazedANDconfused answer, which is correct, you can first notice that you do not need to write arrays if you only want to plot the function, you can simply do:
sage: m = 5
sage: r = 3
sage: w = 6
sage: f(t) = m*r*w^2*cos(t*pi/180)
sage: plot(f, t, 0, 360)
Second, if you want to deal with X and Y arrays (lists), (they are named lists in Python), you can use the Python zip function to avoid iterating among indexes 0
...len(x_coords)-1
by hand:
sage: zip([1,2,3],[4,5,6])
[(1, 4), (2, 5), (3, 6)]
So in your case, you can write the less verbose:
sage: list_plot(zip(x_coords,y_coords))
The following also works:
sage: points(zip(x_coords,y_coords))
4 | No.4 Revision |
To complement @dazedANDconfused answer, which is correct, you can first notice that you do not need to write arrays (they are named lists in Python) if you only want to plot the function, you can simply do:
sage: m = 5
sage: r = 3
sage: w = 6
sage: f(t) = m*r*w^2*cos(t*pi/180)
sage: plot(f, t, 0, 360)
Second, if you want to deal with X and Y arrays (they are named lists in Python), lists, you can use the Python zip function to avoid iterating among indexes 0
...len(x_coords)-1
by hand:
sage: zip([1,2,3],[4,5,6])
[(1, 4), (2, 5), (3, 6)]
So in your case, you can write the less verbose:
sage: list_plot(zip(x_coords,y_coords))
The following also works:
sage: points(zip(x_coords,y_coords))