- 积分
- 55946
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-6-21
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 MeteoInfo 于 2019-3-6 08:58 编辑
更新了MeteoInfoLab的功能,可以使用errorbar()函数绘制误差棒(error bar)图。
固定x, y误差:
- x = arange(0.1, 4, 0.5)
- y = exp(-x)
- errorbar(x, y, fmt='b', xerr=0.2, yerr=0.4)
- title('Fixed error values example')
变化y误差:
- x = arange(0.1, 4, 0.5)
- y = exp(-x)
- # example error bar values that vary with x-position
- error = 0.1 + 0.2 * x
- errorbar(x, y, yerr=error, fmt='b-o')
- title('Variable error bar values example')
为直方图(bar)加误差棒:
- menMeans = [20, 35, 30, 35, 27]std_men = (2, 3, 4, 1, 2)
- n = len(menMeans)
- ind = arange(n)
- width = 0.35
- gap = 0.06
- bar(ind, menMeans, width, yerr=std_men, color='r', ecolor='b', label='Men')
- for j in range(n):
- text(ind[j] + width / 4, menMeans[j] + 2, str(menMeans[j]))
- womenMeans = [25, 32, 34, 20, 25]
- std_women = (3, 5, 2, 3, 3)
- bar(ind + width + gap, womenMeans, width, yerr=std_women, color='y', ecolor='g', label='Women')
- for j in range(n):
- text(ind[j] + + width + gap + width / 4, womenMeans[j] + 2, str(womenMeans[j]))
- xlim(-0.2, 5)
- ylim(0, 40)
- ylabel('Scores')
- xticks(ind + width + gap / 2, ['G1','G2','G3','G4','G5'])
- legend()
- title('Scores by group and gender')
双Y轴Bar图+误差棒:
- menMeans = [20, 35, 30, 35, 27]
- std_men = (2, 3, 4, 1, 2)
- n = len(menMeans)
- ind = arange(n)
- width = 0.35
- gap = 0.06
- ax1 = axes(position=[0.11,0.1,0.75,0.8])
- yaxis(ax1, color='r')
- bar1 = bar(ind, menMeans, width, yerr=std_men, color='r', ecolor='b', label='Men')
- for j in range(n):
- text(ind[j] + width / 4, menMeans[j] + 2, str(menMeans[j]))
- xlim(-0.2, 5)
- ylim(0, 40)
- ylabel('Men Scores', color='r')
- xticks(ind + width + gap / 2, ['G1','G2','G3','G4','G5'])
- title('Scores by group and gender')
- womenMeans = array([25, 32, 34, 20, 25])
- womenMeans = womenMeans * 2
- std_women = (3, 5, 2, 3, 3)
- ax2 = twinx(ax1)
- yaxis(ax2, color='b')
- bar2 = bar(ind + width + gap, womenMeans, width, yerr=std_women, color='b', ecolor='g', label='Women')
- for j in range(n):
- text(ind[j] + + width + gap + width / 4, womenMeans[j] + 2, str(womenMeans[j]))
- xlim(-0.2, 5)
- ylim(0, 80)
- ylabel('Women Scores', color='b')
- legend(bar1+bar2)
|
|