Matplotlib底图drawcounties不起作用

时间:2016-08-08 11:12:20

标签: python matplotlib matplotlib-basemap

相当于标题所说的内容。我的drawcounties命令只是被忽略而没有错误。它只针对某些预测吗?文档没有这么说。

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap, shiftgrid
import scipy

def BasemapParameters():
    """
    Sets up basemap.
    """
    m = Basemap(projection='mill', llcrnrlon = 230, llcrnrlat = 27,
                                   urcrnrlat = 45, urcrnrlon = 261,
                                   area_thresh = 1000., resolution='i')
    m.drawcounties(linewidth=0.5)
    m.drawcoastlines(linewidth=0.7)
    m.drawcountries(linewidth=0.5)
    m.drawstates(linewidth=0.5)
    m.drawmapboundary(linewidth=0.7)

def SavePlot(lvl,parameter,region,hour,padding):
    """
    Saves figure to file with given properties
    """
    plt.savefig('{0}_{1}_{2}_{3}.png'.format(lvl,parameter,region,hour),bbox_inches='tight',pad_inches = padding)
    plt.close("all")
    print('  "{0}_{1}_{2}_{3}.png" created.'.format(lvl,parameter,region,hour))

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
BasemapParameters()
SavePlot('sfc','3hrpcp','sw','000',.07)

输出: enter image description here

2 个答案:

答案 0 :(得分:1)

drawcoastlines()正在绘制具有白色面的多边形,因此它将位于县界之上。

答案 1 :(得分:0)

尝试在drawcounties中设置zorder = 20(或高位),将县行放在国家之上。另请参阅https://github.com/matplotlib/basemap/issues/324

相关问题