如何使用x,y和z轴绘制3D图形?

时间:2017-11-09 10:31:50

标签: python matplotlib

我的日期设置有三列(X,Y和Z轴)。这三列在三个不同的轴上唯一定义。

现在我想导入这些数据并使用python绘制3D图形。

示例数据集如下所示

DataSet Sample Image

1 个答案:

答案 0 :(得分:-2)

import csv
from pandas import read_csv
filename = 'Left.csv'
data = read_csv(filename)
print(data.shape)

#renaming existing columns
data.rename(columns={'epoc (ms)': 'epoc', 'timestamp (-04:00)': 'timestamp',
                 'elapsed (s)': 'elapsed' , 'x-axis (g)': 'xaxis',
                 'y-axis (g)' : 'yaxis' , 'z-axis (g)' : 'zaxis'}, 
inplace=True)

from matplotlib import pyplot
data.hist()
data.plot(kind='density', subplots=True, layout=(3,3), sharex=False)
from pandas.plotting import scatter_matrix
scatter_matrix(data)
pyplot.show()

X = dataset[: 4]
Y = dataset[: 5]
Z = dataset[: 6]

X, Y = np.meshgrid(xs, ys)
Z = generate(X, Y, 0.0)

import matplotlib.pyplot as plt
import time
wframe = None
tstart = time.time()
for phi in np.linspace(0, 360 / 2 / np.pi, 100):

oldcol = wframe

Z = generate(X, Y, phi)
wframe = ax.plot_wireframe(X, Y, Z, rstride=2, cstride=2)

# Remove old line collection before drawing
if oldcol is not None:
    ax.collections.remove(oldcol)

plt.draw()