With this announcement of a Makie update, I finally pushed myself to try it out and must say, I really love it. Both, the plotting script and the output look beautiful and, finally, I am ready to move away from PyPlot, which I like, but I found it tedious to set up (constantly having problems linking it to python) and plotting was sometimes very slow.
Anyway, I played around, and produced the following script/plot for a start:
using CairoMakie
using AbstractPlotting
AbstractPlotting.inline!(false)
x = collect(0:0.1:99.9)
y1 = cumsum(randn(1000))
y2 = cumsum(randn(1000))
y3 = cumsum(randn(1000))
fig, ax, T1 = lines(x, y1,
figure = (resolution = (1000, 600),),
axis = (xlabel = "distance / \$10^{-9}\\,\$m", ylabel = "Temperature / Ā°C",
xgridwidth = 2, xgridstyle = :dash, ygridwidth = 2, ygridstyle = :dash,
xtickalign=1, yticklabelcolor=:red, ytickalign=1), color = :red)
T2 = lines!(x,y2, color = :darkred, linestyle = :dot)
T3 = lines!(x,y3, color = :darkorange1)
leg = Legend(fig, [T1, T2, T3], ["T1", "T2", "T3"],
padding = (10, 10, 5, 5), tellheight=true, tellwidth=false,
orientation = :horizontal, halign = :center)
fig[2,1] = leg
xlims!(ax, 0,100)
ylims!(ax, -25, 50)
fig
So far, so good. There are just 3 things (for now), I couldnāt really figure out and I hope, you can help me with:
- Is it possible to render maths in labels/text fields like in PyPlot or LaTeXStrings?
- I couldnāt get custom dashes to work. In the original dotted lines, for example, spaces are so tight, the line style is virtually indistinguishable from the solid lines. When I type something like
T2.linestyle = [5,3]
orT2.linestyle = [5,2,2,2,2,2]
for dashed or dashed-dotted lines, both graphs for T2 and T3 disappear. So, I guess, there is an error produced in the linestyle of T2 although I am not getting an error message. What am I not understanding? - I want to be able to adjust the tick range. I tried
yticks!(ytickrange=-40:20:70)
andyticks!(fig.scene, ytickrange=-40:20:70)
, but I get anAssertionError: The Scene does not have an axis!
. How can I do this?
Thanks a lot for any help/hints!