如何创建在阵列中的数据matplotlib三维线图? [英] How do I create a 3D line plot in matplotlib from the data in arrays?
问题描述
我已经数值求解使用SciPy的与脚本洛伦兹方程:
I have numerically solved the Lorenz equations using SciPy with the script:
# Lorenz Equations SciPy solver
import numpy as np
from scipy import integrate
from math import cos
from matplotlib import pyplot as plt
a, b = 0, 100
sigma, rho, beta = 10, 28, 8/3
N = 1000000
h = (b-a) / float(N)
def solvr(Y, t):
return [sigma*(Y[1]-Y[0]), Y[0]*(rho-Y[2])-Y[1], Y[0]*Y[1]-beta*Y[2]]
t = np.arange(a, b, h)
asol = integrate.odeint(solvr, [0, 1, 1], t)
x = asol[:,0]
y = asol[:,1]
z = asol[:,2]
现在我想要做的是什么阴谋 X
,是
和以Z < /在3D线(或线框)地块code>(里面全是numpy的ndarrays,如果你不确定)反目成仇。我认为,这将不得不使用matplotlib来完成,但我不挑剔,只要你给我一个解决方案,将绘制三维数据我不在乎我需要导入哪些模块。
Now what I would like to do is plot x
, y
and z
(which are all Numpy ndarrays, if you are unsure) against each other in a 3D line (or wireframe) plot. I think this would have to be done using matplotlib, but I am not picky, so long as you give me a solution that will plot the data in 3D I do not care what modules I need to import.
推荐答案
有是关于如何做线框图在matplotlib网站的 http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#wireframe-plots
There is a brief example / tutorial on how to do wireframe plots (as well as 3d scatter) at the matplotlib site http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#wireframe-plots
这篇关于如何创建在阵列中的数据matplotlib三维线图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!