using PGFPlotsX
using KernelDensity
using ColorSchemes
data = (rand(1000), rand(1000))
k = kde(data)
npoints = 400
es = map(extrema, data)
rgs = map(e -> range(e...; length=npoints), es)
res = pdf(k, rgs...)
res = reverse(transpose(res), dims = 1)
cs = get(ColorSchemes.jet1, res, (minimum(res), maximum(res)))
PNGFiles.save("img.png", cs)
figure = Axis(
PGFPlotsX.Options(
:enlargelimits => "false",
:axis_on_top => nothing,
),
Plot(
PGFPlotsX.Graphics(
PGFPlotsX.Options(
:xmin => first(k.x),
:xmax => last(k.x),
:ymin => first(k.y),
:ymax => last(k.y),
),
"img.png"
)
)
)
fails to show the figure because I guess we put the .tex file in a temp folder. I think we need to put it in the same folder.