Skip to content

Instantly share code, notes, and snippets.

View jkrumbiegel's full-sized avatar

Julius Krumbiegel jkrumbiegel

View GitHub Profile
@jkrumbiegel
jkrumbiegel / subplots_fixed_size.jl
Created May 2, 2021 15:07
makielayout set figure size according to fixed width/height subplots
f = Figure()
[Axis(f[i, j], width = 300, height = 250) for i in 1:3, j in 1:3]
sz = ceil.(Int, GridLayoutBase.determinedirsize.(
Ref(f.layout),
(GridLayoutBase.Col(), GridLayoutBase.Row())))
resize!(f.scene, sz)
@jkrumbiegel
jkrumbiegel / stairs_recipe.jl
Created April 22, 2021 11:01
Basic stairs recipe
@recipe(Stairs) do scene
a = Attributes(
step = :pre, # :center :post
)
merge(a, AbstractPlotting.default_theme(scene, Lines))
end
AbstractPlotting.conversion_trait(x::Type{<: Stairs}) = AbstractPlotting.PointBased()
function AbstractPlotting.plot!(p::Stairs{<:Tuple{<:AbstractVector{<:Point2}}})
@jkrumbiegel
jkrumbiegel / integer_log_ticks.jl
Created April 21, 2021 11:39
integer log ticks
struct IntegerTicks end
MakieLayout.get_tickvalues(::IntegerTicks, vmin, vmax) = ceil(Int, vmin) : floor(Int, vmax)
lines(0.01:0.001:0.99, axis = (yscale = log10, yticks = LogTicks(IntegerTicks())))
measures = ["Endurance", "Coordination", "Speed", "Power Low", "Power Up"]
groups = ["boys", "girls"]
x = LinRange(-8, 9, 15)
f = Figure(resolution = (1000, 500))
axs = [Axis(f[1, i]) for i in 1:length(measures)]
for (i, m) in enumerate(measures)
@jkrumbiegel
jkrumbiegel / legendre.jl
Created April 4, 2021 18:03
legendre polynomials makie
using Legendre, GLMakie
using GeometryBasics, LinearAlgebra, StatsBase
using AbstractPlotting
using AbstractPlotting: get_dim, surface_normals
function Y(θ, ϕ, l, m)
if m < 0
return (-1)^m * √2 * Nlm(l, abs(m)) * Plm(l, abs(m), cos(θ)) * sin(abs(m)*ϕ)
elseif m == 0
return sqrt((2*l+1)/4π)*Plm(l, m, cos(θ))
@jkrumbiegel
jkrumbiegel / pi_animation.jl
Last active April 1, 2021 16:40
Live GLMakie Monte Carlo pi animation
using GLMakie
f = Figure(resolution = (1000, 1000))
ax = Axis(f[1, 1], aspect = 1, limits = (-1, 1, -1, 1))
points = Node(Point2f0[])
colors = Node(Bool[])
@jkrumbiegel
jkrumbiegel / ggplot2_theme_makie.jl
Created January 29, 2021 11:45
ggplot2 theme makie
this looks kind of close
set_theme!(
font = "Arial",
fontsize = 12,
Axis = (
backgroundcolor = :gray92,
xgridcolor = :white,
ygridcolor = :white,
xminorgridcolor = (:white, 0.5),
xminorgridvisible = true,
@jkrumbiegel
jkrumbiegel / histstep.jl
Created January 11, 2021 14:22
Histstep recipe
@recipe(Histstep, values) do scene
Attributes(
bins = 15, # Int or iterable of edges
normalization = :none
)
end
function AbstractPlotting.plot!(plot::Histstep)
@jkrumbiegel
jkrumbiegel / focus_axes.jl
Created December 13, 2020 18:04
focus different laxis with keyboard press
using GLMakie
set_window_config!(float = true)
#
scene, layout = layoutscene(resolution = (1000, 1000))
offscreen_gl = GridLayout(bbox = BBox(-500, -400, -500, -400))
axs = layout[] = [LAxis(scene, title = string(i)) for i in CartesianIndices((2, 2))]
@jkrumbiegel
jkrumbiegel / scatter_interaction.jl
Created November 3, 2020 07:57
activate / deactivate scatter interaction
using AbstractPlotting
using AbstractPlotting.MakieLayout
using GLMakie
set_window_config!(float = true)
##
scene, layout = layoutscene(resolution = (1000, 800))