I am trying with any possible package to plot a classic correlation plot (scatterplots for each variable vs each other and density histogram on the diagonal in the middle). Sometime they are cold correlogram or pairplots. I come from R and Python and it is dead easy with each language to get a plot in no time.
These have been my attempts so far:
Statsplots corrplot @df df corrplot(cols(1:11), grid = false, fc=:thermal)
I was happy to see a macro for this. Works OK but makes julia crash and hang unresponsively with > 11 columns (issue reported on Statsplots with reproducible example: I use the Boston housing dataset).
I tried converting the df to a Matrix but the plot still crashes (at lower dimensional values the results appear slightly different that the df version. Boh?).
Also, not sure what are the heatmaps on the upper part of the grid, but once colored properly they look nice.
AlgebraOfGraphics
So far this is the farthest I have got to. Maybe my experience with ggplot helps. I got my plot with all of the 13th columns with no crash. Pumas documentation on AoG was a great help as well (should be publicised more!).
Only problem I was not able to find how to get a density histogram in the middle diagonal.
HELP PLEASE!!!
This is the crucial part of the plot:
plt = data(df) * (visual(Scatter; color=:dodgerblue) + linear() * visual(; color=:red)) * mapping(cols, permutedims(cols), col=dims(1), row=dims(2))
fg = draw(
plt,
figure=(figure_padding=0, size=(1500, 1500))
)
Makie
I found an old version of code here in Julia Discourse. Sadly Makie has changes a lot its syntax since (probably more than once) and I couldn’t find any good documentation on how to do these type of plots nor any docs on migrating from older versions (what the heck is LAxis?!? is it dead or still used??).
I reproduce the plot code here if somebody can help in bringing it up to current.
HELP PLEASE!!!
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
(from https://discourse.julialang.org/t/makie-pairplot/39298/3)