开发者

Plotting points in python

I want to plot some (x,y) points on the same graph and I don't need any special features at all short of support for polar coordinates which would be nice but not necessary. It's mostly for visualizing my data. Is there a simple way to do this? Matplotlib seems 开发者_如何学运维like way more than I need right now. Are there any more basic modules available? What do You recommend?


Go with matplotlib Chance is that sometime in the future you might need to do more than just "simple" stuff and then you don't need to invest time learning a new plot-tool.

See this link for list of plotting tools for python...


Absolutely. Matplotlib is the way to go.

The pyplot module provides a nice interface to get simple plots up and running fast, especially if you are familiar with MatLab's plotting environment. Here is a simple example using pyplot:

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
x_points = xrange(0,9)
y_points = xrange(0,9)
p = ax.plot(x_points, y_points, 'b')
ax.set_xlabel('x-points')
ax.set_ylabel('y-points')
ax.set_title('Simple XY point plot')
fig.show()


import matplotlib.pyplot as plt 
x = range(1,10) 
y = range(1,10) 
plt.plot(x,y,'o')
plt.show()

Here's a simple line with made up x, y. Note: x and y are lists.

Their lengths should be equal or you'll get a error. Cheers!


I suggest the most good looking plotting library for Python: CairoPlot


You can use the Tkinter canvas widget. It uses rectangular coordinates but of course you can translate to polar. The canvas is pretty much just like it sounds -- a blank canvas on which you can draw points, lines, circles, rectangles, etc.


You could always write a plotting function that uses the turtle module from the standard library.


MathGL is GPL plotting library which have Python interface, arbitrary (including polar) curved coordinates, a lot of plot types, export to PNG, EPS, SVG, widgets, and so on. For 1D plot samples see here.


Have you tried to use pillow?

   from PIL import Image, ImageDraw

   #Set up canvas
   img = Image.new (mode, size)
   draw = ImageDraw.Draw (img)

   #Draw your points
   draw.point (xy, colour) 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜