Reputation: 724
The code
using Plots
pyplot(markershape = :auto)
for i in 1:4
plot!(rand(10), label = "Series " * string(i))
end
savefig("Plot.png")
produces the following plot:
The markers do not appear in the legend, only the data series's line color. This makes it significantly harder to match the lines up with the labels in the legend, especially for those who are colorblind or reading off of a black-and-white printout. Is there a way to display the plot markers as well as line colors in the legend?
Upvotes: 10
Views: 4724
Reputation: 8044
I am adding an answer for posterity - this has been fixed in Plots, so this works:
plot(rand(10,4), markershape = :auto)
Upvotes: 7
Reputation: 883
There's probably a more efficient, straightforward way but you can try plotting the line / markers separately:
using Plots
pyplot(markershape = :auto)
for i in 1:4
x = rand(10)
plot!(x, color=i, marker=false, label="")
scatter!(x, color=i, markersize=10, label = "Series " * string(i))
end
savefig("Plot.png")
label=""
suppresses the legend entry for the line
color=i
ensures that the color of the lines/markers are the same
Upvotes: 3