Display plot in GTK without saving to PNG

Hello,

I have an application where I display a plot in a GTK window, but for that I save it in a png with
savefig and CairoImageSurface. Now I want do display the plot without saving i to a PNG file. Normally this should work by giving CairoImageSurface an array instead of a RGB24 object. But it didnt work

using Cairo, Plots, Statsplots, Statsbase


function make_hist(arr)
#creates histogram from array
...
return plotFig
end

function display_hist(plotFig, arr)
#savefig("plot.png")
...
# instead of saving it to a png display it directly with Cairo
# this doesnt work even when trying to reshape the array
hist = CairoImageSurface(arr, (2,2))

end


plotFig = makehist(arr)
display_hist(plotFig)

Can you elaborate on why it did not work? Also how are you running the code?

One reason I ask is that I do not see anything that will prevent Julia from exiting immediately after it tries to display the plot.