在Python中绘制点

发布于 2024-11-26 12:19:32 字数 139 浏览 0 评论 0原文

我想在同一个图表上绘制一些 (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

别把无礼当个性 2024-12-03 12:19:32

使用 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...

奶茶白久 2024-12-03 12:19:32

绝对地。 Matplotlib 是一条出路。

pyplot 模块 提供了一个很好的界面来快速创建和运行简单的绘图,特别是如果您熟悉MatLab的绘图环境。这是一个使用 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()

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()
穿透光 2024-12-03 12:19:32
import matplotlib.pyplot as plt 
x = range(1,10) 
y = range(1,10) 
plt.plot(x,y,'o')
plt.show()

这是一条由 x、y 组成的简单线。注意:xy 是列表。

它们的长度应该相等,否则会出现错误。干杯!

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!

只等公子 2024-12-03 12:19:32

我推荐最漂亮的 Python 绘图库: CairoPlot

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

王权女流氓 2024-12-03 12:19:32

您可以使用 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.

撞了怀 2024-12-03 12:19:32

您始终可以编写一个使用标准库中的turtle 模块的绘图函数。

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

赤濁 2024-12-03 12:19:32

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.

拥醉 2024-12-03 12:19:32

你尝试过用枕头吗?

   from PIL import Image, ImageDraw

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

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

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) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文