zoukankan      html  css  js  c++  java
  • python3.5.3rc1学习六:画图

    # 可以设置颜色,g代表green, r代表red,y代表yellow,b代表blue
    # linewidth = 5,设置线条粗细
    # label 设置线条名称
    ##plt.plot(x,y,'b',linewidth=5,label='Line One')
    ##plt.plot(x1,y1,'r',linewidth=8,label='Line Two')
    # 绘制柱状图用bar函数
    plt.bar(x, y ,color='g',label='Line One')
    plt.bar(x1, y1 ,color='r',label='Line Two')

    # 给这个图,添加标题和XY轴名称,注意这地方不能输入中文,matplotlib应该
    # 对中文支持不好,写中文,会显示乱码,方块字
    plt.title('Epic Chart')
    plt.ylabel("Y axis")
    plt.xlabel("X axis")

    # 显示图例
    plt.legend()

    #显示网格
    ##plt.grid(True,color='k')

    plt.show()
    print("--------------------")

    x = [5,6,7,8]
    y = [7,3,8,3]

    x1 = [2,5,3,9]
    y1 = [5,3,2,7]

    # 可以设置颜色,g代表green, r代表red,y代表yellow,b代表blue
    # linewidth = 5,设置线条粗细
    # label 设置线条名称
    ##plt.plot(x,y,'b',linewidth=5,label='Line One')
    ##plt.plot(x1,y1,'r',linewidth=8,label='Line Two')
    # 绘制散点图用scatter函数
    plt.scatter(x,y,color='g',label='Line One')
    plt.scatter(x1,y1,color='y',label='Line Two')

    # 给这个图,添加标题和XY轴名称,注意这地方不能输入中文,matplotlib应该
    # 对中文支持不好,写中文,会显示乱码,方块字
    plt.title('Epic Chart')
    plt.ylabel("Y axis")
    plt.xlabel("X axis")

    # 显示图例
    plt.legend()

    #显示网格
    ##plt.grid(True,color='k')

    plt.show()

    参考:http://blog.csdn.net/u011541946/article/details/72898514

  • 相关阅读:
    带提示范围的猜数小游戏--python
    python中字符串的常见操作
    html表单相关标签及属性
    CSS常用属性
    python装饰器
    python闭包的概念及使用
    nuxt.js实战踩坑记录
    vuex填坑记录
    prerender-spa-plugin预处理vue项目实践
    node+express第一次实战踩坑记录
  • 原文地址:https://www.cnblogs.com/51testing/p/7928525.html
Copyright © 2011-2022 走看看