Hi,
I wonder how to avoid to duplicate my plot commands (plot
then plot!
) when I want to add multiples curves using Plots.
Here is the MWE that I would like to simplify:
using Plots
function testplots()
theme(:dark)
ωs=(1,2,3,4)
n=100
xs=[2π*i/n for i ∈ 0:n]
p=nothing
for (i,ω) ∈ enumerate(ωs)
if i==1 # a bit verbose...
p=plot(xs,sin.(ω .* xs),label="ω=$ω")
else
plot!(p,xs,sin.(ω .* xs),label="ω=$ω") # duplicate :(
end
end
p
end
Thank you for your help !