Matplotlib使颜色图没有透明度

时间:2019-02-21 04:22:26

标签: matplotlib

print([company_name.text for company_name in WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@class='cmp-company-directory']//table//td[@class='company_name']/a")))[:10]])

上面的代码产生以下图片: enter image description here

但是,正如您所看到的,右侧的一点显然仍然不是100%不透明的。您可以看到通过该点的网格线。如何使散点图点100%不透明,不透明?

2 个答案:

答案 0 :(得分:1)

一些技巧会有所帮助。在这里,我首先将所有标记绘制成白色,然后再使用所需的颜色在顶部再次绘制。

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

# make-up some data
goal_x = list(range(10))
goal_y = list(range(10))
goal_z = list(range(10))
epoch_arr = np.linspace(0,1,10)

fig = plt.figure(figsize=(8,8))
ax3D = fig.add_subplot(111, projection='3d')
ax3D.set_facecolor('xkcd:salmon')

# First plot: all markers are in white color
ax3D.scatter(goal_x, goal_y, goal_z, s=500, c='w', marker='o', alpha=1.0, zorder=10)

colormap = plt.get_cmap("binary")
norm = matplotlib.colors.Normalize(vmin=min(epoch_arr), vmax=max(epoch_arr))
#ax3D.scatter(goal_x, goal_y, goal_z, s=100, c=colormap(norm(epoch_arr.values)), marker='o')

# Second plot: use intended colormap
ax3D.scatter(goal_x, goal_y, goal_z, s=500, c='b', marker='o', zorder=11)

plt.show()

结果图:

enter image description here

答案 1 :(得分:0)

设置alpha=1就足够了。

ax3D.scatter(..., alpha=1)

或者设置depthshade=False

ax3D.scatter(..., depthshade=False)

两种情况下的结果都是相同的。

enter image description here