Matplotlib三维散点图n

2024-09-30 16:24:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在努力寻找如何在matplotlib中只使用marker edgecolor而没有marker facecolor来制作3d散点图。像空心标记,就像matlab一样。在

说明图片: http://i.stack.imgur.com/LnnOa.jpg

直到现在我都能做到: http://ceng.mugla.edu.tr/sharedoc/python-matplotlib-doc-1.0.1/html/_images/scatter3d_demo.png

从我必须看到的样本数量来看,这远不是理想的。在

有人做到了吗?在


Tags: 标记comhttpmatplotlibstack图片markerjpg
1条回答
网友
1楼 · 发布于 2024-09-30 16:24:49

您可以分别设置edgecolor和{},如下所示:

enter image description here

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

def randrange(n, vmin, vmax):
    return (vmax-vmin)*np.random.rand(n) + vmin

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100
for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
    xs = randrange(n, 23, 32)
    ys = randrange(n, 0, 100)
    zs = randrange(n, zl, zh)
    ax.scatter(xs, ys, zs, facecolor=(0,0,0,0), s=100, marker=m, edgecolor=c)

ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

plt.show()

有几种方法可以将面颜色设置为透明,请参见here。在

相关问题 更多 >