Advertisement

学习内容:Python绘图

阅读量:

今日已初步掌握基础绘图技能
柱状图

复制代码
    # -*- coding: utf-8 -*-
    import matplotlib.pyplot as plt
    plt.style.use('ggplot')#使用ggplot样式
    customers=['ABC','DEF','GHI','JKL','MNO']
    customers_index=range(len(customers))获取索引
    sale_amounts=[127,90,201,111,232]#以上几行为准备数据
    fig=plt.figure()#这是一个基础图,里面可以有多个子图
    ax1=fig.add_subplot(1,1,1)
    ax1.bar(customers_index,sale_amounts,align='center',color='darkblue')
    ax1.xaxis.set_ticks_position('bottom')
    ax1.yaxis.set_ticks_position('left')#设置刻度线,这样美观一些
    plt.xticks(customers_index,customers,rotation=0,fontsize='small')
    plt.xlabel('Custo

全部评论 (0)

还没有任何评论哟~