Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Symphy中绘制三维点列表_Python_Matplotlib_Scipy_Ipython - Fatal编程技术网

Python 在Symphy中绘制三维点列表

Python 在Symphy中绘制三维点列表,python,matplotlib,scipy,ipython,Python,Matplotlib,Scipy,Ipython,如果我有一个3D点列表,比如 pts = [(0,0,0),(1,0,0),(0,2,0),(0,0,3)] 我想用SciPy来绘制它们,我该怎么做?我试过了 plot3d([Point(0,0,0),Point(1,0,0),Point(0,2,0),Point(0,0,3)], (x, -5, 5), (y, -5, 5)) 但这导致了这个错误: -----------------------------------------------------------------------

如果我有一个3D点列表,比如

pts = [(0,0,0),(1,0,0),(0,2,0),(0,0,3)]
我想用SciPy来绘制它们,我该怎么做?我试过了

plot3d([Point(0,0,0),Point(1,0,0),Point(0,2,0),Point(0,0,3)], (x, -5, 5), (y, -5, 5))
但这导致了这个错误:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-54-851ee4534010> in <module>()
----> 1 plot3d([Point(0,0,0),Point(1,0,0),Point(0,2,0),Point(0,0,3)], (x, -5, 5), (y, -5, 5))

/usr/lib/python3.5/site-packages/sympy/plotting/plot.py in plot3d(*args, **kwargs)
   1618     series = []
   1619     plot_expr = check_arguments(args, 1, 2)
-> 1620     series = [SurfaceOver2DRangeSeries(*arg, **kwargs) for arg in plot_expr]
   1621     plots = Plot(*series, **kwargs)
   1622     if show:

TypeError: 'NoneType' object is not iterable
---------------------------------------------------------------------------
TypeError回溯(最近一次调用上次)
在()
---->1 plot3d([点(0,0,0),点(1,0,0),点(0,2,0),点(0,0,3)],(x,-5,5,(y,-5,5))
/plot3d中的usr/lib/python3.5/site-packages/sympy/plotting/plot.py(*args,**kwargs)
1618系列=[]
1619 plot_expr=检查参数(args,1,2)
->1620系列=[SurfaceOver2DRangeSeries(*arg,**kwargs)用于绘图expr中的arg]
1621地块=地块(*系列,**kwargs)
1622如果显示:
TypeError:“非类型”对象不可编辑

最理想的情况是,该解决方案将绘制具有这些垂直面的多面体(四面体),或将它们与线段连接

您可以使用
散点
绘制这些点。如果要使用直线段连接点,一种可能的方法是先绘制点,然后连接点,如下所示:

import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
import itertools

fig = plt.figure()
ax = fig.gca(projection='3d')

# plotting the points
pts = [(0,0,0),(1,0,0),(0,2,0),(0,0,3)]
for p in pts:
    ax.scatter(p[0], p[1], p[2], zdir='z', c='r')

# plotting lines for each point pair
for a, b in itertools.product(pts, pts):
    x = np.linspace(a[0], b[0], 100)
    y = np.linspace(a[1], b[1], 100)
    z = np.linspace(a[2], b[2], 100)
    ax.plot(x, y, z)

ax.legend()
ax.set_xlim3d(0, 1)
ax.set_ylim3d(0, 2)
ax.set_zlim3d(0, 3)

plt.show()