Makie PairPlot

For future reference, in case anyone wants the full working code, here it is. I am on Julia v1.5:

using Makie
using StatsMakie
using DataFrames
using DelimitedFiles
using GLFW
using AbstractPlotting
using MakieLayout

col_names = [:sepalLength, :sepalWidth, :petalLength, :petalWidth, :class]
df = readdlm("iris.csv", ',')|> DataFrame
rename!(df, col_names)
df[!, 1:4] = Float32.(df[!,1:4])
df[!, 5] = String.(df[!, 5])

function  pairplot(df)
    dim = size(df, 2)-1

    scene, layout = layoutscene(30, resolution = (900, 900))
    axs = layout[1:dim, 1:dim] = [LAxis(scene) for i in 1:dim^2]
    x = 0
    for i in 1:dim, j in 1:dim  
	      
	if i == j
	    x+=1
	    plt = plot!(axs[x],Position.stack, histogram, Data(df), Group(:class), df[:, i])
	else
	    x+=1
	    plt = Makie.scatter!(axs[x], Data(df), Group(:class), df[:,j], df[:,i])    
	end
    end
    scene
end

testPlot = pairplot(df)

Also, you can download the data here: https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv - Just make sure to delete the first row of the CSV or it will fail.

Here are the package versions I had:

  [537997a7] AbstractPlotting v0.10.11
  [a93c6f00] DataFrames v0.20.2
  [f7f18e0c] GLFW v3.4.0
  [ee78f7c6] Makie v0.10.0
  [5a521ce4] MakieLayout v0.9.10
  [65254759] StatsMakie v0.2.3

Hopefully this helps future generations of Julians trying to make their own pairplot!

P.S. Thanks to @Dustin_Hess for providing the initial impetus for this!

4 Likes