[SciPy-user] Stupid plot question
Steve Lianoglou
mailinglist.honeypot@gmail....
Thu Nov 20 11:33:02 CST 2008
Hi marco,
On Nov 20, 2008, at 12:02 PM, Marco wrote:
> Hi list!
>
> I have a question about plotting and i haven't found an easy solution
> on the 'net.
>
> I have a 2d matrix with some values in it: basically they are just
> ones or minus ones, and I want to plot them putting a red "square" (or
> "ball" or "something") on screen (on a grid) if the value of that
> matrix element is one and a blue "something" if it is minus one.
>
> How can I do that?
How about this -- start ipython w/ the pylab interface and do the
following:
import random
m = array([random.gauss(0,1) for i in range(100)]).reshape((10,10))
m[m<0] = -1
m[m!=-1]=1
x,y = where(m==-1)
plot(x,y,'bo')
x,y = where(m==1)
plot(x,y,'ro')
In the plot functions, the 'bo' and 'ro' means plot blue/green ('b/o')
open circles ('o')
Hope that helps,
-steve
More information about the SciPy-user
mailing list