gpt4 book ai didi

python - 如何使用 Matplotlib 制作具有光环效果的散点图?

转载 作者:行者123 更新时间:2023-12-05 06:34:33 26 4
gpt4 key购买 nike

我想绘制高斯随机变量的潜在空间其中 x_i~Gaussian(u_i, simga_i)我想像这张图一样代表情节中的不确定性 plot made by someone但是我找不到任何关于如何使用 Matplotlib 执行此操作的 API!

最佳答案

或许您可以试试下面的例子? (修改自 here )

import numpy as np
import matplotlib.pyplot as plt

def normal_pdf(x, mean, var):
return np.exp(-(x - mean)**2 / (2*var))

xmin, xmax, ymin, ymax = (0, 100, 0, 100)

N = 1000
xx = np.linspace(xmin, xmax, N)
yy = np.linspace(ymin, ymax, N)

x = normal_pdf(xx, 50, 75)
y = normal_pdf(yy, 50, 75)

weights = np.array(np.meshgrid(x, y)).prod(0)

plt.imshow(weights, extent=(xmin, xmax, ymin, ymax), cmap=plt.cm.Blues, alpha=0.5)
plt.plot(50, 50, "bo")
plt.tight_layout()
plt.show()

结果:

enter image description here

关于python - 如何使用 Matplotlib 制作具有光环效果的散点图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50196881/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com