[Tutor] Python

Alan Gauld alan.gauld at yahoo.co.uk
Mon Oct 24 12:55:43 EDT 2016


On 24/10/16 15:40, Kadir Sertcanli wrote:
> Hi! I have a function that I want to plot depending on a parameter (’a’), 

OK, But you will need to give us some more details.

> I looked in the beginners guide 

Which beginner's guide are you using?
Plotting is not something normally covered in a Python beginner's
guide - it's not part of standard Python, you usually need some
extra modules to do that.

> I know how to put the axis etc. 

Which plotting module are you using?
Or are you trying to do it using a GUI toolkit (if so which one?)?

> but I don’t know how to involve my function which is 
> V=-(ba^-1 + ca^2) where I have different values for b and c
> so the function I want to plot is depending on a. 

Normally you would generate a set of data pairs and then plot those.
Do you know how to create a list of values based on your input 'a' values?

for example if I wanted to plot the first 10 integer squares
I'd generate a list of values something like:

data = [(n,n**n) for n in range(10)]

That would give me a data list that looked like:

[(0,0),(1,1),(2,4),(3,9),...(9,81)]

I could then plot each pair on a graph or chart of some sort.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list