Draw Box-Plot with matplotlib

Arn*_*aud 2 python matplotlib

Is it possible to plot this kind of chart with matplotlib?

情节

小智 6

在我看来,这很像箱线图。我创建了一个简单的图形,因为同事在展示这样的数据时经常问我这个问题

在此处输入图片说明

如果这是您想要的,示例代码将是

import matplotlib.pyplot as plt

x1 = [-0.46,-1.25,-2.62,0.22]
x2 = [0.24,1.88,-0.49,-0.73,-0.49]
x3 = [-0.44,0.93,0.19,-4.36,-0.88]

fig = plt.figure(figsize=(8,6))

plt.boxplot([x for x in [x1, x2, x3]], 0, 'rs', 1)
plt.xticks([y+1 for y in range(len([x1, x2, x3]))], ['x1', 'x2', 'x3'])
plt.xlabel('measurement x')
t = plt.title('Box plot')
plt.show()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我在这里将其作为IPython笔记本:https : //github.com/rasbt/matplotlib-gallery