Vladimir Mikheev
Vladimir Mikheev

Reputation: 472

How to arrange text annotations in julia makie in one row at the top?

I want to put text annotations along a line on the top. If I write same numbers (no matter which) in y array text will be aligned across center.

let 
    f = Figure()
    ch = ["Ch2", "Ch3", "Ch17", "Ch18", "Ch19"]
    x = Array(0:100:400)
    y = [100, 100, 100, 100, 100]
    ax = Axis(f[1, 1])
    text!(x, y, text = ch, align = (:center, :center), 
    offset = (0, 0),
        color = :black) 
    f 
end

plot 1

but if I change one item in y array

y = [10, 100, 100, 100, 100]

this happens:

plot 2

How could I put "Ch2" to the same position on the top with other annotations?

Upvotes: 1

Views: 471

Answers (1)

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42244

Use ylims!(ax,0,110); to configure your axis.

let
    f = Figure(;ylim=[0,110])
    ch = ["Ch2", "Ch3", "Ch17", "Ch18", "Ch19"]
        x = Array(0:100:400)
    y = [100, 100, 100, 100, 100]
    ax = Axis(f[1, 1]);
    text!(x, y, text = ch, align = (:center, :center),
       offset = (0, 0),color = :black)
    ylims!(ax,0,110)
    f
end

Upvotes: 1

Related Questions