6

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]]).

1 Answer 1

10

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()

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

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 '

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.