Вопрос

I have x1, y1, z1 coordinated at time t1 and I have x2, y2, z2 coordinates at time t2. I want to plot the graph for them.

I have all numpy arrays.

A = [[44.254  44.114  44.353  44.899  45.082] [-0.934  0.506  1.389  0.938  0.881] [44.864  45.225  44.005  42.981  46.356]]

t1 = [0 1.4911475447  1.5248639284  1.2450273089    3.3804382852]

B = [[44.254  48.4877582254 43.0268091866   47.3166368948   47.7110371397] [-0.934  1.0837036817    4.8307913511    6.2772868228    9.6580229826] [44.864   47.1020391758   43.0633715949   42.1564814645   42.0223003717]]

t2 = [0 0.00392157  0.00784314  0.01176471  0.01568627 ]

How can I plot these numpy arrays in graphs?

Это было полезно?

Решение 2

Based on your comment:

I have created 3 plots for every coordinates for A and B. I want to show x, y and z coordinates in one graph only for A and B. how can I show that?

I believe what you are looking for is this:

A = [[44.254, 44.114, 44.353, 44.899, 45.082],[-0.934, 0.506, 1.389, 0.938, 0.881],[44.864, 45.225, 44.005, 42.981, 46.356]]
t1 = [0, 1.4911475447, 1.5248639284, 1.2450273089, 3.3804382852]
B = [[44.254, 48.4877582254, 43.0268091866,  47.3166368948,  47.7110371397], [-0.934, 1.0837036817, 4.8307913511, 6.2772868228, 9.6580229826],  [44.864,  47.1020391758,  43.0633715949,  42.1564814645,  42.0223003717]]
t2 = [0, 0.00392157, 0.00784314, 0.01176471, 0.01568627 ]

for i in range(len(A)):
    figure(1)
    plot(t1,A[i],'o')
    #figure(2)
    plot(t2,B[i],'o')
show()

Note that figure(x) sets the current figure to x or creates it if it doesn't exist. The plot function takes the form plot(x,y,'marker_style') where 'marker_style' is a string as defined here

Другие советы

if you want to show the 3d displacement of A, B, use module mpl_toolkits.mplot3d

A = [[44.254, 44.114, 44.353, 44.899, 45.082],[-0.934, 0.506, 1.389, 0.938, 0.881],[44.864, 45.225, 44.005, 42.981, 46.356]]
t1 = [0, 1.4911475447, 1.5248639284, 1.2450273089, 3.3804382852]
B = [[44.254, 48.4877582254, 43.0268091866,  47.3166368948,  47.7110371397], [-0.934, 1.0837036817, 4.8307913511, 6.2772868228, 9.6580229826],  [44.864,  47.1020391758,  43.0633715949,  42.1564814645,  42.0223003717]]
t2 = [0, 0.00392157, 0.00784314, 0.01176471, 0.01568627 ]

import matplotlib.pyplot as plt 
from mpl_toolkits.mplot3d import Axes3D
ax3d=plt.gca(projection='3d')
ax3d.plot(A[0], A[1], A[2], 'r',)
ax3d.scatter(A[0], A[1], A[2], c='r')

ax3d.plot(B[0], B[1], B[2], 'g',)
ax3d.scatter(B[0], B[1], B[2], c='g')

plt.show()

the plot result is as below: enter image description here

if you want to add an annotation to mark the start point of A, B, see question post

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top