I’m trying to plot a contour with marginal plots.
I’ve created a user recipe:
@userplot JPlot
@recipe function f(h::JPlot)
m, x, y = h.args
mx = vec(sum(m, dims=1))
my = vec(sum(m, dims=2))
link := :both
grid := false
layout := @layout [t _
c{0.8w, 0.8h} r]
# main
@series begin
seriestype := :contour
subplot := 2
x, y, m
end
seriestype := :line
# top
@series begin
subplot := 1
x, mx
end
# right
@series begin
subplot := 3
orientation := :horizontal
y, my
end
end
which I tested with:
using Distributions
mv = MvNormal([0, 0], [1 0; 0 1])
xs = range(-3, 3, length=100)
ys = range(-3, 3, length=100)
m = [pdf(mv, [x, y]) for y in ys, x in xs]
jplot(m, xs, ys)
This is what I get:
What happened to the marginal plot on the right?
Thanks
DD