请问Plots包怎么调整legend的linewidth呀

发现Plots包legend的linewidth好像和line的linewidth不一样。
比如下面这个图,我希望legend第二条线(橙色线)的linewidth为3

using Plots
plot(1:10, rand(10))
	plot!(1:10, rand(10), lw=3)

Try Makie:

using CairoMakie

f = Figure();

ax = f[1, 1] = Axis(f)

lines!(0..15, sin, label = "sin", color = :blue)

lines!(0..15, cos, label = "cos", color = :red, linewidth = 3)

f[1, 2] = Legend(f, ax, "Trig Functions", framevisible = false)

f

Plots 包或许要手动设置一下 legend? 换个backend?

2 个赞

好的,谢谢你,我去看看这个包!

Plots找不到怎么设置 :joy:

你可以尝试一下using Plots;plotly(),应该能方便地得到你想要的结果,例如:

Input:
@time begin
           using Plots;plotly()
           p=plot(framestyle=:box)
           for i in 1:10
               p=plot!(rand(10),label="-$(i)-",linewidth=i)
           end
       end;display(p)

Output:
0.005322 seconds (13.53 k allocations: 639.188 KiB)

结果如图:

2 个赞