基于矩阵的python三维绘图



我有一个由…创建的数据集

import random
count = []
for i in range(1, 4):
    for j in range(3, 6):
        for k in range(15,19):
            count.append((i, j, k, random.random()))

我想创建countijk对的3d图(总共3个图)。我已经浏览了以下示例:http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#surface-情节,但它们似乎都在创造价值。如何绘制所需的曲面图或网格图?

我必须破折号,但这就是我尝试绘制数据的方式-count(i,j)的示例-请参阅最后一行左右的索引切片。如果需要,很乐意进一步查看。

>>> from mpl_toolkits.mplot3d import Axes3D
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> import random
>>> 
>>> count = []
>>> for i in range(1, 4):
...     for j in range(3, 6):
...         for k in range(15,19):
...             count.append((i, j, k, random.random()))
...             
...         
...     
... 
>>> data = np.array(count)
>>> fig = plt.figure()
>>> ax = fig.gca(projection='3d')
>>> 
>>> # I think this is the sort of thing you want:
>>> 
>>> ax.plot_trisurf(data[:,0], data[:,1], data[:,3])
/usr/local/lib/python2.7/dist-packages/matplotlib/delaunay/triangulate.py:103: DuplicatePointWarni
ng: Input data contains duplicate x,y points; some values are ignored.
  DuplicatePointWarning,
<mpl_toolkits.mplot3d.art3d.Poly3DCollection object at 0x46e8390>
>>> plt.show()

相关内容

  • 没有找到相关文章

最新更新