I want to plot the result of a numerical method for a three dimensional system of ODEs. My output is in the form (let's suppose we have computed three steps):
import numpy as np
v= np.array([[1,2,3], [4,5,6], [7,8,9]])
Where the first value in every 3-tuple is the x coordinate, the second is y coordinate and the third is the z coordinate.
I would like the most simple and efficient way of plotting these points on a 3D grid. The problem seems to be that the data should be formated like np.array([[1,4,7], [2,5,8], [3,6,9]]).
asked Oct 31, 2016 at 21:42
D1X
5,5145 gold badges26 silver badges42 bronze badges
1 Answer 1
You can plot the result in 3D like this:
import matplotlib.pyplot as plt, numpy as np
from mpl_toolkits.mplot3d import Axes3D
v= np.array([[1,2,3], [4,5,6], [7,8,9]])
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot(v[:,0],v[:,1],v[:,2])
plt.show()
answered Nov 1, 2016 at 6:57
Angus Williams
2,34421 silver badges21 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
john k
E:\Python35\Lib\site-packages\matplotlib\tight_layout.py:177: UserWarning: The left and right margins cannot be made large enough to accommodate all axes decorations. warnings.warn('The left and right margins cannot be made large '
lang-py