How to add a title to a Makie
plot? I would to produce a plot like the following using Makie instead of Plots.jl:
julia> using Plots; plot(randn(10), title="my random numbers")
How to add a title to a Makie
plot? I would to produce a plot like the following using Makie instead of Plots.jl:
julia> using Plots; plot(randn(10), title="my random numbers")
This will need some better integration, but this works:
using Makie
theplot = lines(randn(10))
pos = lift(pixelarea(theplot)) do area
x = widths(area)[1] ./ 2
Vec2f0(x, 10) # offset 10px, to give it some space
end
title = text(
"my random numbers", align = (:center, :bottom),
position = pos, camera = campixel!, raw = true, textsize = 40, # in pixel,
)
hbox(theplot, title)
title
function…
Just because this is a first result in a google search, I wish to point out that currently (09/04/2019) there is a title function:
using Makie
theplot = lines(randn(10))
sc = title(theplot,"Title")
Yep, that’s actually an implementation of Simon’s suggestion here
Yeah, I noticed that, but the actual existence of that implementation took longer to find.
I thought It was worth it to mention it in this topic that has higher visibility than other thing, right?
Anyone notice this title doesn’t work for 3D plots?
FWIW, Makie: add title to plot - #3 by aramirezreyes no longer works. Three other options:
plt = scatter(randn(10), axis = (title = "my title",))
f, ax, s = scatter(...); ax.title = "my title"
or a manually created axis with Axis(fig[1, 1], title = "my title")
. Or if there’s an object you want to give a title even though it doesn’t have an attribute like that, you can place a label in the upper protrusion of the layout cell. For example, to give a slider a title (doesn’t make sense but anyway):
f = Figure()
Slider(f[1, 1])
Label(f[1, 1, Top()], "a title", padding = (0, 0, 10, 0))
fig[0, :] = Label(fig, "my title")
works for me.
Yes this one is very useful for super titles or section titles
Is there a declarative way to add a supertitle? The issue I face with
figuregrid = draw(spec)
figuregrid.figure[0, :] = Label(figuregrid.figure, "my title")
is that re-running that line adds an additional title on top. I would like an idempotent command that I can run without worrying about execution order or multiplicity.
Not really, because in my philosophy there is not really just one type of super title, at least with the flexible layout model there is no “slot” that could be reserved for the super title. I guess one could add a separate title to the figure that pushes down its internal grid layout, instead of being added to it, and that would enable an idempotent supertitle command. But I’m not sure that adding this complexity gains so much