[Tutor] Plotting a Linear Equation

Alan Gauld alan.gauld at btinternet.com
Thu Apr 21 23:40:51 CEST 2011


"Emanuel Woiski" <woiski at gmail.com> wrote

> easy:

I love your sense of humour!

> import pylab as pl
> import numpy as np
> x1,x2,n,m,b = 0.,10.,11,2.,5.
> x = np.r_[x1:x2:n*1j]
> pl.plot(x,m*x + b); pl.grid(); pl.show()

Now, given this is a list for beginners to Python, could you
try explaining what you did there and how the OP, or
anyone else for that matter, might use it?

Or were you really just trying to establish that if
you try hard you can write Python that is as
difficult to read as Perl?

>>  I want to use matplotlib (or similar) to plot an equation in
>>  (y=mx+b) or standard form (Ax + By = C).  I could make
>>  two points out of those manually, but I was wondering if anyone 
>> knew of
>>  an easier way. Thanks.

Alan G.




More information about the Tutor mailing list