Re: [Matplotlib-users] plotting constant functions

2006-09-05 Thread Eric Firing
Davidlohr Bueso A. wrote: > Hi, > > I am having trouble graphing constant functions in matplotlib (a simple > y = 2). Here is a simple test script I'm using: > > from pylab import * > > def f(x): > return 2 Try return 2*ones(shape(x)) The problem is that you are returning a scalar

Re: [Matplotlib-users] plotting constant functions

2006-09-05 Thread Matt
Use this to plot it: plot([x], [f(x)])you need the square brackets. -Matt --- "Davidlohr Bueso A." <[EMAIL PROTECTED]> wrote: > Hi, > > I am having trouble graphing constant functions in > matplotlib (a simple > y = 2). Here is a simple test script I'm using: > > from pylab import * > > d

[Matplotlib-users] plotting constant functions

2006-09-05 Thread Davidlohr Bueso A.
Hi, I am having trouble graphing constant functions in matplotlib (a simple y = 2). Here is a simple test script I'm using: from pylab import * def f(x): return 2 x = arange(1, 4) plot(x, f(x)) show() When I run it, I get this error: Traceback (most recent call last): File "test",