This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using CairoMakie | |
f = Figure(fonts = (; regular = "CMU")) | |
Label(f[1, 1], "Weights", fontsize = 20) | |
gl = GridLayout(f[2, 1]) | |
for i in 1:5, j in 1:5 | |
text = if i <=3 && j <= 3 | |
rich("w", subscript("$i,$j")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@recipe(AxisFunction) do scene | |
default_theme(scene, Lines) | |
end | |
Makie.data_limits(::AxisFunction) = Rect3f(Point3f(NaN), Vec3f(NaN)) | |
Makie.boundingbox(::AxisFunction, space::Symbol = :data) = Rect3f(Point3f(NaN), Vec3f(NaN)) | |
function Makie.plot!(p::AxisFunction) | |
func = p[1] | |
# # could use transf to compute points equidistant in transformed space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f, ax, sc = scatter(cumsum(randn(1000)), markersize = 3, label = "Scatter") | |
leg = Legend(f[1, 2], ax) | |
leg.entrygroups[][1][2][1].elements[1].attributes.markersize = Observable(10) | |
notify(leg.entrygroups) | |
f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = Figure() | |
ax = Axis(f[1, 1]) | |
relative_y(ax, x, y_rel) = lift(ax.finallimits) do lims | |
y = lims.origin[2] + lims.widths[2] * y_rel | |
Point(x, y) | |
end | |
text!(ax, relative_y(ax, 50, 0.8), text = "50, 0.8", yautolimits = false) | |
text!(ax, relative_y(ax, 50, 0.2), text = "50, 0.2", yautolimits = false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using GLMakie | |
f = Figure() | |
b = Button(f[1, 1], tellwidth = false) | |
gl = GridLayout(f[2, 1]) | |
function delete_contents!(gl::GridLayout) | |
for c in contents(gl) | |
if c isa GridLayout | |
delete_contents!(c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = Figure() | |
for i in 1:3, j in 1:3 | |
Axis(f[i, j], title = "$i, $j") | |
end | |
# pretend you get f here and want to change Axes you can't directly get as variables | |
ax = f.content[3] | |
ax.subtitle = "f.content[3]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = Figure() | |
Axis(f[1, 1], title = "Hey") | |
Axis(f[1, 2], title = "Ho") | |
Colorbar(f[1, 3]) | |
Label(f[2, :], "A long spanning label") | |
Colorbar(f[3, 1:2], vertical = false) | |
f | |
function show_layout(f::Figure) | |
fig = Figure(size = size(f.scene), backgroundcolor = :gray50) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function detect_png_physical_size(io::IO) | |
png_signature = "\x89PNG\r\n\x1a\n" | |
seekstart(io) | |
if String([read(io, UInt8) for _ in 1:length(png_signature)]) != png_signature | |
throw(ArgumentError("Not a png file")) | |
end | |
function read_chunk_length() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using GLMakie | |
slides = [ | |
(gl) -> begin | |
for i in 1:2, j in 1:2 | |
lines(gl[i, j], cumsum(randn(1000))) | |
end | |
return (; title = "A slide with two Axis") | |
end, | |
(gl) -> begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = Figure() | |
main_ax = Axis(f[1, 1]) | |
inset_gl = GridLayout(f[1, 1], alignmode = Outside(15)) | |
inset_ax_1 = Axis(inset_gl[1:2, 1]) | |
Label(inset_gl[1:2, 1, Right()], "(a)", valign = :top, padding = (5, 0, 0, 0)) | |
inset_ax_2 = Axis(inset_gl[1, 2]) | |
Label(inset_gl[1, 2, Left()], "(b)", valign = :top, padding = (0, 5, 0, 0)) | |
inset_ax_3 = Axis(inset_gl[2, 2]) | |
Label(inset_gl[2, 2, Left()], "(c)", valign = :top, padding = (0, 5, 0, 0)) | |
for ax in [inset_ax_1, inset_ax_2, inset_ax_3] |
NewerOlder