Access the plot object by Seaborn to put in Plots.plot as a subplot

47 views Asked by At

Julia v1.9.2 Plots v1.38.0 Seaborn v1.1.1

I am trying to combine a heatmap (sbplot) from Seaborn and a regular Plots.plot (hist) as below, but am getting ERROR: MethodError: no method matching getindex(::Nothing, ::Int64)

using Seaborn
using Plots

sbplot = Seaborn.heatmap([1 1.5; 3 2.8])
hist = Plots.bar([1,1.5, 2.,7])
combo = Plots.plot(sbplot,hist,layout=(2,1))

sbplot has many attributes, and I have tried sbplot.figure, .plot, .get_figure, etc., but could not get a compatible object to put together with hist. Any suggestions? Thank you!

1

There are 1 answers

0
Jen-Feng Hsu On

Thanks @kirklong for the suggestion! This workaround did work for me.

using Seaborn
using Plots
using Images

sbplot = Seaborn.heatmap([1 1.5; 3 2.8])
Seaborn.savefig("SBplot.png")
sbplot_Plots = Plots.plot(Images.load("SBplot.png")) # Load in and make it a Plots plot object

hist = Plots.bar([1,1.5, 2.,7])

heat_hist_plot = Plots.plot(sbplot_Plots, hist, layout = @layout([A{0.8h}; B]))