Skip to content

Instantly share code, notes, and snippets.

View jkrumbiegel's full-sized avatar

Julius Krumbiegel jkrumbiegel

View GitHub Profile
@jkrumbiegel
jkrumbiegel / makie_tab_interface.jl
Created July 25, 2025 17:51
Makie tab interface using deletion
function tear_down!(tabgrid)
for e in @view tabgrid.content[end:-1:begin]
if e.content isa GridLayout
tear_down!(e.content)
Makie.GridLayoutBase.remove_from_gridlayout!(e)
else
delete!(e.content)
end
end
trim!(tabgrid)
@jkrumbiegel
jkrumbiegel / bar.jl
Created July 18, 2025 09:31
dodged bar smaller bar inside AlgebraOfGraphics
mapping(
["X", "X", "X"],
[1, 2, 3],
dodge = ["A", "B", "C"],
color = ["A", "B", "C"],
) * visual(BarPlot, direction = :x) +
mapping(
["X", "X", "X"],
[0.7, 1.5, 2.2],
dodge = ["A", "B", "C"],
@jkrumbiegel
jkrumbiegel / gist:52a90ff54149617ff7eb2431433d9e80
Created July 18, 2025 09:30
dodged bar scatter markers AoG
mapping(
["X", "X", "X"],
[1, 2, 3],
dodge = ["A", "B", "C"],
color = ["A", "B", "C"],
) * visual(BarPlot, direction = :x) +
mapping(
[0.7, 1.8, 2.2],
["X", "X", "X"],
dodge_y = ["A", "B", "C"]
@jkrumbiegel
jkrumbiegel / pretalx_pdf_schedule.jl
Last active July 21, 2025 14:30
juliacon pretalx custom pdf schedule
using JSON
using Downloads
using Typst_jll
using Dates
url = "https://pretalx.com/juliacon-2025/schedule/export/schedule.json"
json = JSON.parsefile(Downloads.download(url))
@jkrumbiegel
jkrumbiegel / makie_align_axes_around_value.jl
Created June 8, 2025 19:25
makie_align_axes_around_value.jl
f = Figure()
ax1 = Axis(f[1, 1])
scatter!(randn(100) .- 1)
ax2 = Axis(f[1, 2])
scatter!(randn(100) .* 2)
on(ax1.finallimits) do lims
aligned = 0
(xmin, ymin), (xmax, ymax) = extrema(lims)
dy1, dy2 = (ymin, ymax) .- aligned
@jkrumbiegel
jkrumbiegel / cairomakie_draw_into_buffer.jl
Created June 5, 2025 07:42
CairoMakie draw into buffer
using CairoMakie
using CairoMakie.Colors
sz = (400, 300)
px_per_unit = 2
img = fill(ARGB32(1, 0, 0, 1), ((sz .* px_per_unit) .+ (200, 0))...)
surf = CairoMakie.Cairo.CairoImageSurface(img)
f = Figure(size = sz)
scatter(f[1, 1], cumsum(randn(100)))
@jkrumbiegel
jkrumbiegel / inner_stroke.jl
Created May 14, 2025 11:02
inner poly rect box stroke Makie
r1 = Rect2f((10, 20), (5, 8))
r2 = Rect2f((20, 30), (5, 8))
f, ax, _ = poly(r1)
linewidth = Observable(20)
r2_pixel = lift(ax.scene.camera.projectionview, ax.scene.viewport, linewidth) do _, _, lw
mi, ma = extrema(r2)
_mi = Makie.project(ax.scene, mi) .+ 0.5lw
@jkrumbiegel
jkrumbiegel / makie_slopeline_screen_space.jl
Created April 2, 2025 14:15
Makie slopeline length in screen space
using LinearAlgebra: normalize
f = Figure()
ax1 = Axis(f[1, 1])
slope1 = 2
data1 = [1 0; slope1 1] * randn(2, 500)
scatter!(ax1, data1, alpha = 0.1)
ax2 = Axis(f[1, 2])
slope2 = -0.5
data2 = [1 0; slope2 1] * randn(2, 500)
@jkrumbiegel
jkrumbiegel / stacked_twin_axes.jl
Created March 27, 2025 13:18
Stacked twin axis Makie
f = Figure()
main_ax = Axis(f[1, 1])
twin_ax_layout = GridLayout(f[1, 1, Right()])
twin_axis_pairs = map(1:3) do i
data_axis = Axis(f[1, 1])
label_axis = Axis(twin_ax_layout[1, i], width = 0, alignmode = Outside(), yaxisposition = :right)
hidedecorations!(data_axis)
hidespines!(data_axis)
hidexdecorations!(label_axis)
linkyaxes!(data_axis, label_axis)
@jkrumbiegel
jkrumbiegel / makie_hexagon_axis.jl
Created March 12, 2025 18:50
Makie hexagon axis plot
hexradius = 45
hexpoly(p, hexradius) = Makie.Polygon(Ref(p) .+ Point2f[hexradius .* (cos(a), sin(a)) for a in range(pi / 6, 13pi / 6; length=7)[1:6]])
s = Scene(camera = campixel!)
function hex_center(q::Int, r::Int, radius)
# axial coordinates
x = radius * sqrt(3) * (r + q / 2)
y = radius * (3/2) * q