-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
legend markers are not rendered in scatter plot #290
Comments
Looks like a bug. If you come up with a fix, contributions are welcome! |
Don't know if this is addressed at all, but in case anyone else needs a work around and only cares about showing the colors for certain labels in the legend (so it is at least worth something), I've been setting the font colors with l = ax.legend(fancybox=0)
for i, text in enumerate(l.get_texts()):
text.set_color(colors[i]) |
Another more direct workaround is to leave the labels off of the scatter plots and then plot empty arrays with fig, ax = plt.subplots()
ax.scatter(np.random.randn(10), np.random.randn(10), color="red", label="data1")
ax.scatter(np.random.randn(10), np.random.randn(10), color="blue", label="data2")
ax.legend(title="Cluster", loc="best", framealpha=0) you can do fig, ax = plt.subplots()
ax.scatter(np.random.randn(10), np.random.randn(10), color="red")
ax.plot([], [], "o", color="red", label="data1")
ax.scatter(np.random.randn(10), np.random.randn(10), color="blue")
ax.plot([], [], "o", color="blue", label="data2")
ax.legend(title="Cluster", loc="best", framealpha=0) and the legend will include the colored markers. |
mpld3/mplexporter#54 should fix this issue! |
I got a similar issue with scatter plot as #185. But framealpha hack is not effective here.
It seems that svg has
g
elements for markers, but they are not rendered in legend. Are there something wrong with my code?The text was updated successfully, but these errors were encountered: