简体   繁体   English

3D散点图

[英]3D scatter plot

I want to create a 3D scatter plot. 我想创建一个3D散点图。 There is a fourth parameter which will be indicated by a colour map. 有第四个参数,将由色图指示。 I can program in Python and IDL, but was wondering has anybody created such a scatter plot and what is the best tool to use? 我可以用Python和IDL进行编程,但是想知道有人创建了这样的散点图,什么是最好的工具?

Thanks. 谢谢。

There are two main options matplotlib and Mayavi . matplotlibMayavi有两个主要选项。 At the moment matplotlib is more popular, so you will find info easier. 目前,matplotlib更受欢迎,因此您会发现信息更容易。 Mayavi tends to be more advanced so you would use it if matplotlib is not enough for your use case(for example too slow). Mayavi倾向于更高级,因此如果matplotlib不足以满足您的用例(例如,速度太慢),则可以使用它。 An example using matplotlib: 使用matplotlib的示例:

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

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100

xs = np.random.randint(0, 10, size=n)
ys = np.random.randint(0, 10, size=n)
zs = np.random.randint(0, 10, size=n)
colors = np.random.randint(0, 10, size=n)
ax.scatter(xs, ys, zs, c=colors, marker='o')
plt.show()

在此处输入图片说明

You can find more examples here . 您可以在此处找到更多示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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