mike_k
September 26, 2019, 10:54am
1
Dear community,
I want to create a plot with several lines that have different line-styles (e.g., solid, dashed, dotted,…), and to add these styles to the legend of the plot (to fit for a black-white publication). Is there any built-in option for that in the meanwhile, or a better work around than this one?
Thank you in advance and kind regards,
Michael
Hi, I found that PyPlot is actually better for this purpose, here’s my code:
subplots()
xlabel("x",fontsize=14)
title("Title",fontsize=14)
yscale("log")
grid("on")
ylabel("Time (s)",fontsize=14)
plot(X,time1,label="Label1",color="orange",linewidth=3)
plot(X,time2,label="Label2",color="green",linestyle="--",linewidth=3)
plot(X,time3,label="Label3",color="blue",linestyle="-.",linewidth=3)
legend()
xticks(X)
ax=gca()
ax.set_xlim([X[1],X[end]])
ax.legend(loc="upper left")
Hope it helps.
2 Likes
I haven’t used Gadfly, but with Plots you can do this:
using Plots
plot(rand(10, 5),
line = [:solid :dash :dot :dashdot :dashdotdot],
color = :black)
1 Like
For Gadfly, there’s examples of the linestyle
aesthetic here .
In the tutorial , Guide.linekey
is marked as to be done.
1 Like
mike_k
September 26, 2019, 2:36pm
5
Thank you all. I gave a try using Plots together with PyPlot as backend, and this seems to work fine for my purposes.