Python matplotlib中的面颜色更改边颜色

Python matplotlib中的面颜色更改边颜色,python,matplotlib,Python,Matplotlib,我正在尝试删除一个圆柱体的绘图中的边缘颜色,我在其中设置了alpha和FaceColor。但是,如果我也设置了面颜色,我仍然可以看到边缘颜色。如果我删除了alpha=0.5语句,那么问题就解决了,但是我需要在plot\u surface()中设置linewidth=0,以解决这个问题: ax.plot_surface(X, Y, Z, edgecolor=None, facecolors=col1, alpha=0.5, linewidth=0) p、 s:我觉得这个问题不值得回答,但佩尔:

我正在尝试删除一个圆柱体的绘图中的边缘颜色,我在其中设置了alpha和FaceColor。但是,如果我也设置了面颜色,我仍然可以看到边缘颜色。如果我删除了
alpha=0.5
语句,那么问题就解决了,但是我需要在
plot\u surface()中设置
linewidth=0
,以解决这个问题:

ax.plot_surface(X, Y, Z, edgecolor=None, facecolors=col1, alpha=0.5, linewidth=0)


p、 s:我觉得这个问题不值得回答,但佩尔:,我添加了它作为一个快速答案,以便将问题标记为已解决

这与您指定
edgecolor=None
而不是
edgecolors
有关吗?我尝试了这两种方法,但都不起作用。这是一个视觉错误还是您正在绘制一个由圆圈内接的十面体棱镜?我认为是一个视觉错误设置
plot_surface()
中的
linewidth=0
似乎适用于您的示例,尽管您仍然可以看到一些边,很可能是因为透明面略微重叠,
import numpy as np
from matplotlib import cm
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.linalg import norm
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
import random
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
origin = np.array([0, 0, 0])
#axis and radius

p0 = np.array([0, 0, 0])
p1 = np.array([8, 8, 8])
R = 4
#vector in direction of axis
v = p1 - p0
#find magnitude of vector
mag = norm(v)
#unit vector in direction of axis
v = v / mag
#make some vector not in the same direction as v
not_v = np.array([1, 0, 0])
if (v == not_v).all():
    not_v = np.array([0, 1, 0])
#make vector perpendicular to v
n1 = np.cross(v, not_v)
#normalize n1
n1 /= norm(n1)
#make unit vector perpendicular to v and n1
n2 = np.cross(v, n1)
#surface ranges over t from 0 to length of axis and 0 to 2*pi
t = np.linspace(0, mag, 200)
theta = np.linspace(0, 2 * np.pi, 100)
#use meshgrid to make 2d arrays
t, theta = np.meshgrid(t, theta)
#generate coordinates for surface
X, Y, Z = [p0[i] + v[i] * t + R * np.sin(theta) * n1[i] + R * np.cos(theta) *        n2[i] for i in [0, 1, 2]]
col1 = plt.cm.Blues(np.linspace(0,1,200)) # linear gradient along the t-axis
col1 = np.repeat(col1[np.newaxis,:, :], 100, axis=0) # expand over the theta-    axis


ax.plot_surface(X, Y,Z, edgecolor = None, facecolors = col1, alpha = 0.5)
#plot axis
ax.plot(*zip(p0, p1), color = 'red')
ax.set_xlim(0, 10)
ax.set_ylim(0, 10)
ax.set_zlim(0, 10)
plt.axis('off')
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)

plt.show()
ax.plot_surface(X, Y, Z, edgecolor=None, facecolors=col1, alpha=0.5, linewidth=0)