zoukankan      html  css  js  c++  java
  • 用 python matplotlib 画图 简单记录

    我们团队准备改造现有的监控机制
    由于性能原因
    考虑将业务数据趋势图
    由VBA生成改造成用python的matplotlib




    顺便记录下一个cookbook
    http://www.scipy.org/Cookbook
    -------
    还有
    http://www.lfd.uci.edu/~gohlke/pythonlibs/




    ===========================================


    依次安装
    python 2.7
    numpy-MKL-1.6.2.win32-py2.7
    matplotlib-1.1.0.win32-py2.7
    basemap-1.0.4.win32-py2.7(测试下)
    ----------------------

    (办公室网连接sourceforge 好像不行了)

    本人山寨代码如下

    from mpl_toolkits.basemap import Basemap
    import matplotlib.pyplot as plt
    import numpy as np
    # set up orthographic map projection with
    # perspective of satellite looking down at 50N, 100W.
    # use low resolution coastlines.
    # don't plot features that are smaller than 1000 square km.
    map = Basemap(projection='ortho', lat_0 = 30, lon_0 = 100,
                  resolution = 'l', area_thresh = 1000.)
    # draw coastlines, country boundaries, fill continents.
    map.drawcoastlines()
    map.drawcountries()
    map.fillcontinents(color = 'coral')
    # draw the edge of the map projection region (the projection limb)
    map.drawmapboundary()
    # draw lat/lon grid lines every 30 degrees.
    map.drawmeridians(np.arange(0, 360, 30))
    map.drawparallels(np.arange(-90, 90, 30))
    #lat/lon coordinates of five cities.
    lats = [39.9, 22.5]
    lons = [116.4, 114]
    cities=['BeiJing','ShenZhen']
    # compute the native map projection coordinates for cities.
    x,y = map(lons,lats)
    # plot filled circles at the locations of the cities.
    map.plot(x,y,'bo')
    # plot the names of those five cities.
    for name,xpt,ypt in zip(cities,x,y):
        plt.text(xpt+50000,ypt+50000,name)
    plt.show()

    -------------

    原代码参见http://www.scipy.org/Cookbook/Matplotlib/Maps

    效果如下

  • 相关阅读:
    ASP.NET 父页面取子页面的值 TC
    C#代码规范 TC
    [Serializable]在C#中的作用NET 中的对象序列化 TC
    ADO.NET连接数据库 TC
    ASp.net 剖析三层架构 TC
    转载反编译Silverlight项目 TC
    ASP.NET FileUpload上传图片方法并解决上传文件大小 TC
    C#控件一览表 前所未有的震撼(太详细了) TC
    ASP.NET C#上传图片生成缩略图 TC
    项目总结 TC
  • 原文地址:https://www.cnblogs.com/4admin2root/p/2633441.html
Copyright © 2011-2022 走看看