Created
January 17, 2020 08:04
-
-
Save jkrumbiegel/a322614cf7e5661e14d5b3fbbc6ffbf6 to your computer and use it in GitHub Desktop.
Iris MakieLayout corrplot
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 Makie, MakieLayout, AbstractPlotting, Statistics, StatsMakie, StatsBase, RDatasets | |
@recipe(CorrLayout) do scene | |
Theme( | |
markersize = 5 * AbstractPlotting.px | |
) | |
end | |
function AbstractPlotting.plot!(scene::Scene, ::Type{CorrLayout}, attributes::Attributes, mat) | |
n = size(mat, 2) | |
C = cor(mat) | |
layout = GridLayout(n, n) | |
layout[1:n, 1:n] = axs = [LAxis(scene) for i in 1:n, j in 1:n] | |
for i in 1:n, j in 1:n | |
vi = view(mat, :, i) | |
vj = view(mat, :, j) | |
ax = axs[i, j] | |
# s = Scene(scene, Reactive.value(pixelarea(scene))) | |
if i == j # histograms are on the diagonal | |
histresult = fit(Histogram, vi) | |
barplot!(ax, midpoints(histresult.edges[1]), histresult.weights) | |
elseif i > j | |
scatter!(ax, vj, vi, markersize = attributes[:markersize]) | |
else | |
scatter!(ax, vj, vi, markersize = attributes[:markersize]) | |
end | |
end | |
scene, axs, layout | |
end | |
data = RDatasets.dataset("datasets", "iris") | |
mat = Matrix(data[!, 1:4]) | |
## | |
scene, layout = layoutscene() | |
_, axs, sublayout = corrlayout!(scene, mat; markersize = 5 * AbstractPlotting.px) | |
layout[1, 1] = sublayout | |
scene |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment