怎样做班级网站/搜索引擎营销方式
无意中发现了一个很好的软件测试网站,忍不住分享一下给大家。觉得很实用,所以分享给大家。点这里可以跳转到教程。
#coding=utf8
'''
matplotlib.pyplot.bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs)
绘制条形图。绘制带有矩形边界的条形图通过如下设置:
left, left + width, bottom, bottom + height
(left, right, bottom and top edges)输入参数:
left:标量序列。表示条形图左边x坐标。
height:标量或者标量序列。条形图的高度。
width:标量或者数组,可选参数。条形图宽度默认为:0.8。
bottom:标量或者数组,可选参数。条形图y坐标,默认值为None。
color:标量或者数组,可选参数。条形图前景色。
edgecolor:标量或者数组,可选参数。条形图边界颜色。
linewidth:标量或者数组,可选参数。条形图边界宽度。如果为None,使用默认linewidth;如果为0,不画边界。默认为None。
tick_label:字符串或者数组,可选参数。条形图的tick标记,默认为None。
xerr:标量或者数组,可选参数。如果不是None,将把生成的errorbars用在条形图上,默认为None。
yerr:标量或者数组,可选参数。如果不是None,将把生成的errorbars用在条形图上,默认为None。ecolor:标量或者数组,可选参数。指定errorbars的颜色,默认为None。
capsize:标量,可选参数。确定errorbars上限的长度,默认为None,从errorbar.capsize rcParam获取到值。error_kw:字典类型,可选参数。kwags参数被传给errorbar方法。ecolor和capsize可能在这被指定而不是作为一个单独的kwargs。align:{'center','edge'},可选参数,默认:'center'。如果是'edge',通过左边界(条形图垂直)和底边界(条形图水平)来使条形图对齐。如果是'center',将left参数解释为条形图中心坐标。通过传递一个给width设置复数,来使条形图以右边界进行对齐。orientation:{'vertical','horizontal'},可选参数。设置条形图方向。
log:布尔类型,可选参数。如果为true,设置轴到log scale。默认为False。返回值:
bars:matplotlib.container.BarContainer。带有所有bar与errorbar的容器。-------------------------------------------------------------------------------
matplotlib.pyplot.barh(bottom, width, height=0.8, left=None, hold=None, **kwargs)
创建一个水平条形图。创建一个带有矩形边界的水平条,设置如下:
left, left + width, bottom, bottom + height
(left, right, bottom and top edges)
输入参数:
bottom:标量或者数组。条形图的y坐标。
width:标量或者数组。条形图宽度。
height:标量序列,可选参数,默认值为:0.8。条形图的高度。
left:标量序列。条形图左边的X坐标返回值:
matplotlib.patches.Rectangle实例。'''
import matplotlib as mpl
import matplotlib.pyplot as plt
import sys#提供汉字支持
mpl.rcParams["font.family"]="sans-serif"
mpl.rcParams["font.sans-serif"]=u'SimHei'def Vbar():#绘制垂直条形图rect=plt.bar(left=(0,1,2),height=(40,30,50),width=0.35,align="center")#显示汉字,前面加u,代表使用unicode#y轴标记plt.ylabel(u'班级')#x轴标记plt.xlabel(u'人数')#设置x轴可读显示plt.xticks((0,1,2),(u'一年级',u'二年级',u'三年级'))#显示柱状图信息plt.legend((rect,),(u"图例",))#显示绘制图片plt.show()def Hbar():#绘制水平条形图rect=plt.barh(bottom=(0,1,2),height=0.35,width=(40,30,50),align="center")#显示汉字,前面加u,代表使用unicode#y轴标记plt.ylabel(u'类别')#x轴标记plt.xlabel(u'数量')#设置x轴可读显示plt.yticks((0,1,2),(u'文学类',u'历史类',u'哲学类'))#显示柱状图信息plt.legend((rect,),(u"图例",))#显示绘制图片plt.show()if __name__=="__main__":while True:choice=raw_input(u"输入你的选择(V,H):")if choice in ["v","V"]:Vbar()elif choice in ["h","H"]:Hbar()else:print "Exit..."sys.exit()