Skip to content

Instantly share code, notes, and snippets.

View jkrumbiegel's full-sized avatar

Julius Krumbiegel jkrumbiegel

View GitHub Profile
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))
@jkrumbiegel
jkrumbiegel / invisible_legend_elements.jl
Created October 16, 2020 08:10
Invisible legend elements and reordering
scene, layout = layoutscene(resolution = (600, 600))
ax = layout[1, 1] = LAxis(scene)
lineobjects = [lines!(ax, 1:10, randn(10), color = rand(RGBf0)) for _ in 1:5]
invisible_element = LineElement(color = :transparent, linewidth = 0, linestyle = nothing)
reorder(elems) = collect(vec(permutedims(reshape(elems, :, 2))))
layout[1, 2] = LLegend(scene,
using AbstractPlotting, AbstractPlotting.MakieLayout, GLMakie
set_window_config!(float = true)
let
scene, layout = layoutscene(resolution = (800, 800))
ax = layout[1, 1] = LAxis(scene)
data = Node(zeros(Bool, 30, 30))
data[][1, 1] = true
@jkrumbiegel
jkrumbiegel / makie_integer_ticks.jl
Created September 10, 2020 06:55
Makie Integer Ticks
struct IntegerTicks end
MakieLayout.get_tickvalues(::IntegerTicks, vmin, vmax) = ceil(Int, vmin):floor(Int, vmax)
scene, layout = layoutscene(resolution = (400, 400))
ax = layout[1, 1] = LAxis(scene)
xlims!(ax, 0, 10)
ax.xticks = IntegerTicks()
scene