Matplotlib – How to make the marker face color transparent without making the line transparent

See @Pelson’s answer below for the correct way to do this with one line.

You can do this in a hacky way by sticky taping together two independent Line2D objects.

th = np.linspace(0, 2 * np.pi, 64)
y = np.sin(th)
ax = plt.gca()

lin, = ax.plot(th, y, lw=5)
mark, = ax.plot(th, y, marker="o", alpha=.5, ms=10)

ax.legend([(lin, mark)], ['merged'])
plt.draw()

demo figure

see here for explanation

Leave a Comment