3

我一直在努力寻找如何在 matplotlib 中制作只有标记边缘颜色和没有标记面颜色的 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

根据我必须可视化的样本数量,这远非理想。

有没有人设法做到这一点?

4

1 回答 1

2

您可以单独设置edgecolorand facecolor,如下所示:

在此处输入图像描述

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

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

于 2015-01-17T20:12:56.797 回答