tpa*_*ker 8 plot julia plots.jl
代码
using Plots
pyplot(markershape = :auto)
for i in 1:4
plot!(rand(10), label = "Series " * string(i))
end
savefig("Plot.png")
Run Code Online (Sandbox Code Playgroud)
产生以下情节:
标记不会出现在图例中,只会显示数据系列的线条颜色.这使得将线条与图例中的标签进行匹配变得非常困难,特别是对于那些色盲或读取黑白打印输出的人.有没有办法在图例中显示绘图标记和线条颜色?
我正在为后代添加一个答案 - 这已在 Plots 中修复,所以这有效:
plot(rand(10,4), markershape = :auto)
Run Code Online (Sandbox Code Playgroud)
可能有一种更有效、更直接的方法,但您可以尝试分别绘制线条/标记:
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")
Run Code Online (Sandbox Code Playgroud)
label=""抑制该行的图例条目
color=i确保线条/标记的颜色相同