【发布时间】:2022-11-12 19:28:17
【问题描述】:
我已经定义了以下自定义类:
class Point():
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
我有一个名为points 的Point 对象列表。
我现在需要在 3D 散点图中绘制这些点。
有没有一种快速的方法来获取我可以在类定义中实现的所有点的 x 值?
我知道我可以做到这一点
xs = [p.x for p in points]
ys = ...
但这有点乏味。有人知道在我的课堂上可能有一种方法来整合它吗?
或者也许我需要定义一个PointList 类?
谢谢
【问题讨论】:
标签: python matplotlib python-class