Skip to content

Instantly share code, notes, and snippets.

@jkrumbiegel
Created July 22, 2020 11:03
Show Gist options
  • Save jkrumbiegel/e721eec3ebfdeb32ad4bc8d2d2ec8efb to your computer and use it in GitHub Desktop.
Save jkrumbiegel/e721eec3ebfdeb32ad4bc8d2d2ec8efb to your computer and use it in GitHub Desktop.
margin histogram in makielayout
using AbstractPlotting
using AbstractPlotting.MakieLayout
using StatsBase
##
scene, layout = layoutscene(resolution = (600, 600))
data = Node(randn(200, 2) * [1 2; 2 1])
xhist = @lift(fit(Histogram, $data[:, 1], nbins = 20))
yhist = @lift(fit(Histogram, $data[:, 2], nbins = 20))
mainax = layout[2, 1] = LAxis(scene)
topax = layout[1, 1] = LAxis(scene)
rightax = layout[2, 2] = LAxis(scene)
colsize!(layout, 1, Relative(0.8))
rowsize!(layout, 2, Relative(0.8))
scatter!(mainax, data)
barplot!(topax, @lift(midpoints($xhist.edges[1])), @lift($xhist.weights))
barplot!(rightax, @lift(midpoints($yhist.edges[1])), @lift($yhist.weights), direction = :x)
linkxaxes!(mainax, topax)
linkyaxes!(mainax, rightax)
scene
@jkrumbiegel
Copy link
Author

grafik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment