如何在Matplotlib上叠加

如何在Matplotlib上叠加,matplotlib,plot,Matplotlib,Plot,我想用matplotlib画一个内部有两点的三角形。以下是我正在使用的代码: plt.figure() triangleEdges = np.array([[0,0],[1,0],[0.5,0.5*np.sqrt(3)]]) colors = ['red', 'green', 'blue'] t1 = plt.Polygon(triangleEdges, facecolor="none", edgecolor='black', linewidth=2) t1.set

我想用matplotlib画一个内部有两点的三角形。以下是我正在使用的代码:

plt.figure()
triangleEdges = np.array([[0,0],[1,0],[0.5,0.5*np.sqrt(3)]])
colors = ['red', 'green', 'blue']
t1 = plt.Polygon(triangleEdges, facecolor="none", 
              edgecolor='black', linewidth=2)
t1.set_facecolor('xkcd:salmon')
plt.gca().add_patch(t1)

drawSoftmaxPoint('blue',100,np.array([0.2,0.1,0.7]) )
drawSoftmaxPoint('red',100,np.array([0.5,0.1,0.7]))



plt.show()

根据代码,三角形内部应该有两个点,但看起来背景覆盖了它们。我如何使它们可见


谢谢大家!

您可以在多边形中使用alpha和z顺序来实现它(从matplotlib的文档)。只需尝试将alpha值设置在0和1之间,以检查是否可以看到您的点。然后在不同的元素上使用z顺序,以确保多边形的填充最深(最后面)。zorder的示例:

您需要提供一个服务,否则无法帮助。具体来说,我们完全不清楚什么是
drawSoftmaxPoint