Menu
|
The page is in the process of being translated. |
using GLMakie
fig = Figure()
menu = Menu(fig, options = ["viridis", "heat", "blues"], default = "blues")
funcs = [sqrt, x->x^2, sin, cos]
menu2 = Menu(fig,
options = zip(["Square Root", "Square", "Sine", "Cosine"], funcs),
default = "Square")
fig[1, 1] = vgrid!(
Label(fig, "Colormap", width = nothing),
menu,
Label(fig, "Function", width = nothing),
menu2;
tellheight = false, width = 200)
ax = Axis(fig[1, 2])
func = Observable{Any}(funcs[1])
ys = lift(func) do f
f.(0:0.3:10)
end
scat = scatter!(ax, ys, markersize = 10px, color = ys)
cb = Colorbar(fig[1, 3], scat)
on(menu.selection) do s
scat.colormap = s
end
notify(menu.selection)
on(menu2.selection) do s
func[] = s
autolimits!(ax)
end
notify(menu2.selection)
fig
Menu direction
You can change the direction of the menu with direction = :up or direction = :down. By default, the direction is determined automatically to avoid cutoff at the figure boundaries.
using GLMakie
fig = Figure()
menu = Menu(fig[1, 1], options = ["A", "B", "C"])
menu2 = Menu(fig[3, 1], options = ["A", "B", "C"])
menu.is_open = true
menu2.is_open = true
fig
Attributes
options
Defaults to ["no options"]
The list of options selectable in the menu. This can be any iterable of a mixture of strings and containers with one string and one other value. If an entry is just a string, that string is both label and selection. If an entry is a container with one string and one other value, the string is the label and the other value is the selection.