3

I have a set of points created through a python program which belongs to different clusters. I would like to plot it on a graph so that points in different clusters should be plotted with different colours.

UPDATE

In my case I have a univariate data ( marks of a test). Looking for a way to plot it.

I have two clusters that are stored in two arrays. Like x=[1,20,10,4], y=[1644,34444]. I would like to plot it like as in a cluster

5
  • Can you show what the data looks like and I can suggest the function used to plot Commented Apr 21, 2011 at 17:42
  • Hope now the question is clear Commented Apr 21, 2011 at 17:53
  • are the points like (1,1644),(20,1644)....(1,34444)....? Commented Apr 21, 2011 at 18:12
  • no. x and y are two different clusters Commented Apr 21, 2011 at 18:18
  • but for any plot you need a x and y co-ordinate whats the x and whats the y here? Commented Apr 21, 2011 at 18:22

3 Answers 3

8

you can use matplotlib. I'm not sure to understand exactly your need, but it could be something like this :

from pylab import *
for (x, y) in clusters:
    plot(x, y, '+')
show() # or savefig(<filename>)
Sign up to request clarification or add additional context in comments.

3 Comments

Beware, from ... import * is not a good practice... Here from pylab import plot, show is enough.
@Emmanuel: no need to take guidelines too literally. pylab is that part of matplotlib that was designed to be interactive (replacing matlab's plotting), hence from pylab import * is a common idiom. It's not really being used in production code - for that you just use the regular matplotlib APIs and classes
Thanks for the info. It would be helpful if you tell about plotting one dimensional data ( marks in a test )
0

matplotlib is an easy to use plotting library. Should do what you want. Assuming your problem isn't one of the clustering itself, you should be able to use that library for what you want.

I've also had some joy with Chaco. It has a steeper learning curve, but has some neat features (if you wanted to interact with the data, for example).

Comments

0

svg.charts is a nice module available at PyPI.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.