如何在同一张图里画两个GMM的contour?

using Distributions
using Plots
theme(:wong)
gr()
a = MvNormal([0,0.5], [0.2, 0.6])
b = MvNormal([1,1], [0.4, 1])
c = MvNormal([-0.5, -1],[1, 0.5] )
gmm1 = MixtureModel(MvNormal[a,b,c], [0.2, 0.3, 0.5])

x1 = -3:0.01:6
y1 = -3:0.01:6
Z1 = [pdf(gmm1,[i,j]) for i in x1, j in y1]

d = MvNormal([3,2], [0.3, 0.1])
e = MvNormal([2,2], [1, 0.6])
f = MvNormal([2, 3],[0.5, 1] )
gmm2 = MixtureModel(MvNormal[d,e,f], [0.1, 0.5, 0.4])

# x2 = 3:0.01:5
# y2 = 3:0.01:5

Z2 = [pdf(gmm2,[i,j]) for i in x1, j in y1]
# surface(x, y, Z, showaxis=true)
contour(x1,y1,Z1,grid=0,fill=false)
contour!(x1,y1,Z2, grid=0,fill=false)

目前用在这种第二次添加的方式, colorbar 是不统一的
而且,如果fill=true, 图只能显示最后一个

放下图, :sweat_smile:

而且这样画出来,其实效果是两个子图, colorbar 也不一样

EMM,那你想画成什么样?把两个GMM再按0.5概率混合一次那样?

不是,是想让两个GMM在一个尺度下。。。他这提示 share a colorbar., 我总感觉这俩不在一个尺度上

而且fill 的那个, 第二个图总会覆盖第一个图。。。。

请教一下,contour的其他argument如何用?例如:

contour(x1, x2, y, levels=15, alpha=0.6, fill=true, size=(400, 400), c=:lightrainbow)

其中c还能设置什么?哪里可以找到contour的说明文件?help里只提到levels和fill

这里提到的所有颜色都能用:ColorSchemes · Plots (juliaplots.org)

1 个赞