How to plot a set of points in python?
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
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>)
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).
svg.charts
is a nice module available at PyPI.
精彩评论