用 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

 

 

效果如下

 

posted @ 2012-08-11 10:49  4admin2root  阅读(527)  评论(0编辑  收藏  举报