Partially transparent scatter plot, but with a solid color bar

我是研究僧i 提交于 2019-11-28 19:11:18

Alright, I found one way to do it, that looks relatively clean: (using the ColorBar object from the question)

color_bar.set_alpha(1)
color_bar.draw_all()
# pylab.draw() or pyplot.draw() might be necessary

It would be great to get a confirmation that this is the most robust way to proceed, though! :)

This is a huge, ugly hack. But no other way would work. Maybe someone else can improve.

fig1 = pylab.figure()
fig2 = pylab.figure()
ax1 = fig1.add_subplot(111)
ax2 = fig2.add_subplot(111)
ax1.scatter(range(10), range(10), c=range(10), alpha=0.2)
im = ax2.scatter(range(10), range(10), c=range(10), alpha=1.0)
fig1.colorbar(im, ax=ax1)
fig1.show()

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!