Plot a function with matplotlib?
Miki Tebeka
miki.tebeka at gmail.com
Sat May 19 10:22:17 EDT 2012
> I'm looking for an interface closer to
> what my HP graphing calculator would use, i.e. something like this:
>
>
> plot(lambda x: sin(x*pi), # function or expression to plot,
> start=0.0,
> end=2.0,
> )
>
> and have step size taken either from some default, or better still,
> automatically calculated so one point is calculated per pixel.
>
> Is there a way to do this in iPython or matplotlib?
I don't think there is, but using range and list comprehension you can write a little utility function that does that:
HTH
--
Miki Tebeka <miki.tebeka at gmail.com>
http://pythonwise.blogspot.com
def simplot(fn, start, end):
xs = range(start, end+1)
plot(xs, [fn(x) for x in xs)])
More information about the Python-list
mailing list