Adding pdf/png into existing pgfplots

Hi,
I’m trying to add a node to a pgfplot that contains a pdf/png file.

Here is what I have until now

using Plots
pgfplotsx()
fig1 = plot(1:5)
savefig(fig1, "fig1.png")
savefig(fig1, "fig1.pdf") # just to create a figure in the folder
fig2 = plot([1,2])
plot!(fig2,[NaN],add=raw"\pgfdeclareimage{img}{fig1.pdf}
\node (img1) at (1.5,1.25) {\pgfuseimage{img}};", extra_kwargs=:subplot)

But the file is not presented in the figure.
The node tex code is taken from a stack question.
fig2

I’ve already tried

f_pdf = load(file)
heatmap!(fig,f_pdf)

But it complains about memory issue, which I don’t understand (in pfgplotsx() backend).

I think you need the absolute path to that file:

using Plots
pgfplotsx()
fig1 = plot(1:5)
savefig(fig1, "fig1.png")
savefig(fig1, "fig1.pdf") # assuming this is run in homedir()
fig2 = plot([1,2])
plot!(fig2,[NaN],add="\\pgfdeclareimage{img}{$(homedir())/fig1.pdf}
\\node (img1) at (1.5,1.25) {\\pgfuseimage{img}};", extra_kwargs=:subplot)

Oh, thanks!
Now it’s working!