简体   繁体   中英

Python - Plotting a 3 dimensional array

I've not yet worked with a 3 dimensional array and I'm a little confused on how to approach this plotting with its relative large size.

There is relative code to this, but it's not necessarily needed in this case.

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D

mask1 = (8e+11 < Mvir1) & (Mvir1 < 2.4e+12)
MWmasses1 = Mvir1[mask1]
MWpos1 = Pos1[mask1]

MWpos1 will have a shape of (1220, 3)

and it looks like this,

[[  51618.7265625   106197.7578125    69647.6484375 ]
 [  33864.1953125    11757.29882812   11849.90332031]
 [  12750.09863281   58954.91015625   38067.0859375 ]
 ..., 
 [  99002.6640625    96021.0546875    18798.44726562]
 [  27180.83984375   74350.421875     78075.78125   ]
 [  19297.88476562   82161.140625      1204.53503418]]

If there is any additional information left out that is needed, I will be more than happy to post it.

I appreciate any help that is given.

Unpack the values and plot

x,y,z = zip(*MWpos1)
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(x, y, z, '.')
ax.legend()
plt.show()

Read more at the tutorial

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM