Я пытался построить 4 отдельных гауссовых распределения на одном графике, пока у меня есть это:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import multivariate_normal
from mpl_toolkits.mplot3d import Axes3D
mu = [[-1, -1], [-1, 1], [1, -1], [1, 1]]
sig = [[[0.02, 0], [0, 0.01]], [[0.1, 0], [0, 0.05]], [[0.03, 0], [0, 0.01]], [[0.02, 0], [0, 0.08]]]
x = np.arange(-2, 2, 0.01)
y = np.arange(-2, 2, 0.01)
X, Y = np.meshgrid(x, y)
pos = np.empty(X.shape + (2,))
pos[:, :, 0] = X
pos[:, :, 1] = Y
gaussians_list = []
for i in range(len(mu)):
gaussians_list.append(multivariate_normal(mu[i], sig[i]))
# Make a 3D plot
fig = plt.figure()
ax = fig.gca(projection='3d')
for i in range(len(mu)):
ax.plot_surface(X, Y, gaussians_list[i].pdf(pos), cmap='viridis', linewidth=0)
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
plt.show()

, нокажется, что 3 первых распределения покрываются последним в точках, которые равны нулю.я ищу способ:
нарисовать части, где распределения не равны нулю, чтобы они не покрывали друг друга
, хотя я знаю, что могу суммировать их, чтобы сгенерировать одно единственное распределение, но яИнтересно, есть ли способ заставить код выше работать
заранее спасибо