Draw Box-Plot with matplotlib

梦想与她 提交于 2021-02-08 13:47:21

问题


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

Plot


回答1:


This looks a lot like a boxplot to me. I created a simple figure because colleagues often ask me about it when I am presenting my data like this

enter image description here

If this is what you are looking for, the example code would be

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()

enter image description here

I have it as an IPython notebook here: https://github.com/rasbt/matplotlib-gallery



来源:https://stackoverflow.com/questions/24337726/draw-box-plot-with-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!