python、matplotlib、multi-arm bandit中的绘图正态分布

python、matplotlib、multi-arm bandit中的绘图正态分布,python,matplotlib,Python,Matplotlib,如何在matplotlib中绘制多个正态分布图像,如上图所示?这种绘图称为“小提琴”绘图: 这种图称为“小提琴”图: import numpy as np from matplotlib import pyplot as plt # Generate 5 actions with different reward distributions data = np.random.randn(1000, 5) * [1, 0.5, 1.5, 1, 0.5] + [0, 1, -1, 2, -0.5


如何在matplotlib中绘制多个正态分布图像,如上图所示?

这种绘图称为“小提琴”绘图:


这种图称为“小提琴”图:

import numpy as np
from matplotlib import pyplot as plt

# Generate 5 actions with different reward distributions
data = np.random.randn(1000, 5) * [1, 0.5, 1.5, 1, 0.5] + [0, 1, -1, 2, -0.5]

plt.violinplot(data)
plt.xlabel('Action')
plt.ylabel('Reward distribution')