scatter plot

Friends,

Someone please suggest me how to make scatter plot with a matrix data such as the one attached. Is is possible to feed a matrix to scatter function directly and plot the value in each row of the matrix.

Thanks,
Bala

test (600 Bytes)

Hi Bala,

the following may help ...

from pylab import *
m = loadtxt("test") # load data

# first solution
figure(1)
for i in xrange(len(m[:, 0])):
     # run through the columns and plot matrix data
     # over index-array
    scatter(arange(len(m[i, :])), m[i, :])

# second solution with same result
figure(2)
# generate a x-array, whose elements should correspond to
# the matrix elements (as above)
x = ones(len(m[:, 0]))[:, newaxis]*arange(len(m[0, :]))
scatter(x, m)

show()

for more options of scatter see for instance the docu at
http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=scatter#matplotlib.pyplot.scatter
or the examples at
http://matplotlib.sourceforge.net/examples/pylab_examples/scatter_demo.html?highlight=scatter
http://matplotlib.sourceforge.net/examples/pylab_examples/scatter_demo2.html?highlight=scatter

best regards Matthias

ยทยทยท

On Tuesday 19 May 2009 14:07:27 Bala subramanian wrote:

Friends,

Someone please suggest me how to make scatter plot with a matrix data such
as the one attached. Is is possible to feed a matrix to scatter function
directly and plot the value in each row of the matrix.

Thanks,
Bala