通过Seaborn访问绘图对象,将其作为子图放入Plots.plot中

问题描述 投票:0回答:1

朱莉娅 v1.9.2 绘图 v1.38.0 Seaborn v1.1.1

我正在尝试将 Seaborn 的热图(sbplot)和常规的 Plots.plot(hist)结合起来,如下所示,但是我得到了 错误:MethodError:没有与 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 有很多属性,我尝试过 sbplot.figure、.plot、.get_figure 等,但无法获得兼容的对象与 hist 放在一起。有什么建议么?谢谢!

julia seaborn plots.jl
1个回答
0
投票

感谢@kirklong 的建议!这个解决方法对我来说确实有效。

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]))
© www.soinside.com 2019 - 2024. All rights reserved.