首页 > 其他 > 详细

matplot 代码实例2

时间:2015-04-25 10:39:09      阅读:257      评论:0      收藏:0      [点我收藏+]

技术分享

 

要画出如上图(注意原点有边距),怎么办呢?

简单而优雅,请看代码:

#!/usr/bin/env python
# coding=utf-8

import matplotlib.pyplot as plt


def loadData():
    x = [1,2,3,4,5]
    y = [1,4,8,9,7]
    labelsx = [Apple,Banana,Orange,Pear,Cherry]
    return x,y,labelsx

def drawGraph():
    x,y,labels_x = loadData()
    plt.plot(x,y,ro)
    plt.xticks(x,labels_x,rotation=vertical)

    plt.xlabel("Fruits")
    plt.ylabel("Price")
    plt.title(" The Price of the Fruits")

    plt.margins(0.3)
    plt.subplots_adjust(bottom=0.15)
    plt.show()

if __name__=="__main__":
    drawGraph()

 

参考:http://matplotlib.org/examples/index.html

matplot 代码实例2

原文:http://www.cnblogs.com/jkmiao/p/4455452.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!