Answers:
此代码使箱形图然后放置一个圆圈,标记每个框的均值。您可以通过在调用中指定marker参数来使用其他符号scatter
。
import numpy as np
import pylab
# 3 boxes
data = [[np.random.rand(100)] for i in range(3)]
pylab.boxplot(data)
# mark the mean
means = [np.mean(x) for x in data]
pylab.scatter([1, 2, 3], means)