Ask Your Question

Plotting f(1),f(2),f(3),...?

asked 2015-03-20 10:08:39 -0500

this post is marked as community wiki

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

Hi, everyone.

I am new to this, and only just beginning to use this stuff. I want to define a function, and see how it behaves. It's a function of natural numbers. How can I plot it (say, f(1),f(2),f(3),...) on the xy-plane?

Best regards,

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-03-20 17:58:21 -0500

Eugene gravatar image

See 2D Plotting, consider plot and line.

It may be more comfortable to first calculate your data points (as an numpy array, or a list of tuples) and then try to visualize them using different methods from plotting examples and docs.

edit flag offensive delete link more

answered 2015-03-20 10:42:52 -0500

kcrisman gravatar image

Here is one example.

list_plot([f(i) for i in range(10)])

But there are many, many ways to do this. For instance, if you are plotting a function that returns an ordered pair, then this might be appropriate.

points([f(i) for i in range(10)],marker='^')
edit flag offensive delete link more


Thanks. Actually my function is recursive, so I should plot (1,f(1)), then compute f(2) using f(1), and then plot (2,f(2)), and so on. But, I get the idea.

Kim gravatar imageKim ( 2015-03-20 10:59:55 -0500 )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


Asked: 2015-03-20 10:08:39 -0500

Seen: 228 times

Last updated: Mar 20 '15