在Python中绘制点
我想在同一个图表上绘制一些 (x,y) 点,并且我根本不需要任何特殊功能,除非支持极坐标,这会很好但不是必需的。它主要用于可视化我的数据。有没有一种简单的方法可以做到这一点? Matplotlib 似乎超出了我现在的需要。还有更多的基本模块可用吗?你有什么建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
使用 matplotlib 很有可能,在未来的某个时候,您可能需要做的不仅仅是“简单”的事情,然后您不需要投入时间学习新的绘图工具。
请参阅此 链接 了解 Python 绘图工具列表...
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...
绝对地。 Matplotlib 是一条出路。
pyplot 模块 提供了一个很好的界面来快速创建和运行简单的绘图,特别是如果您熟悉MatLab的绘图环境。这是一个使用 pyplot 的简单示例:
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:
这是一条由 x、y 组成的简单线。注意:x 和 y 是列表。
它们的长度应该相等,否则会出现错误。干杯!
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!
我推荐最漂亮的 Python 绘图库: CairoPlot
I suggest the most good looking plotting library for Python: CairoPlot
您可以使用 Tkinter 画布小部件。它使用直角坐标,但当然您可以转换为极坐标。画布就像听起来一样——一块空白画布,您可以在上面绘制点、线、圆、矩形等。
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.
您始终可以编写一个使用标准库中的
turtle
模块的绘图函数。You could always write a plotting function that uses the
turtle
module from the standard library.MathGL 是 GPL 绘图库,具有 Python 接口,任意(包括极)曲线坐标,多种绘图类型,导出为 PNG、EPS、SVG、小部件等。有关一维绘图示例,请参阅此处。
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?