Ask Your Question
0

How can I plot points given by code?

asked 2014-12-09 16:11:30 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

I want to plot the points, that I get from the following code all together in one plot. How can I do that?

for x in range(11):
  for y in range(ceil(0.5*(x+4)),(2*x-3)):
        print (x,y,x+y-2)

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-12-09 20:21:05 +0100

mmarco gravatar image

I think the function you are looking for is list_plot.

edit flag offensive delete link more
0

answered 2014-12-09 16:22:09 +0100

kcrisman gravatar image

You could make a list of all your points and then use the function point or you could make a point for each one and then add them (by syntax like point((1,2,3))+point((2,3,4))+point((3,4,5))).

edit flag offensive delete link more

Comments

1

Ideally I would like to use a method that works for an infinite number of points (ie. for bigger ranges too). So adding them one by one is not ideal.

How do I make a list and plot it?

edit: got it

L = [(x,y,x+y-2) for x in range(11) for y in range(ceil(0.5*(x+4)),min((2*x-3),11))]
points(L)

Thanks!

legeh gravatar imagelegeh ( 2014-12-09 17:08:33 +0100 )edit

Great! When you said 'infinite' I started getting worried, but I think you meant 'arbitrary' - Sage does not yet support plotting infinity :)

kcrisman gravatar imagekcrisman ( 2014-12-09 17:53:42 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-12-09 16:11:30 +0100

Seen: 415 times

Last updated: Dec 09 '14