這是我用matplotlib
製作的plot。它使用pylab
的bar
和scatter
方法。 我有3個問題:想要發胖的錯誤
如何使錯誤欄變胖? bar
沒有API,我可以看到。 如何正確指定軸? 如何停止顯示x軸標籤?
第一個是最重要的,因爲我不知道。我想還有一件事是,如何在這裏顯示圖像?我已經看到它完成,但不知道如何。
下面是代碼:
import numpy as np
from pylab import *
data1 = np.linspace(12,22,7)
data2 = np.random.normal(loc=15,scale=5,size=10)
data3 = [11,12,18,19,20,26,27]
data = [data1,np.abs(data2),data3]
# n = number of groups
def layout(n,r=7):
s = r**2 # r = radius of each data point
#layout from 1 to 100
margin = 5
spacer = 10
group_width = (100 - 2*margin - (n-1)*spacer)*1.0/n
dot_width = r
bar_width = group_width - dot_width
current = margin
rL = list()
for i in range(n):
rL.append(current) # x for point
rL.append(current + 3) # x for bar
current += group_width + spacer
return s, bar_width, rL
s, w, xlocs = layout(len(data))
for group in data:
x = xlocs.pop(0)
for e in group:
scatter(x,e,s=s,color='k')
m = np.mean(group)
e = np.std(group)
x = xlocs.pop(0)
o = bar(x,m,width=w,color='0.6',
yerr=e, ecolor='k')
show()
alt text http://img210.imageshack.us/img210/8503/screenshot20100206at703.png
To s圖表如何點擊圖像圖標並粘貼到圖像的直接鏈接。我認爲你粘貼到包含圖像的imageshack頁面的鏈接。 – Mark 2010-02-07 00:45:54