我正在尝试使用底图将数据绘制到正交投影上。出于某种原因,颜色经过右上角的边缘。关于如何避免这种情况的任何建议?
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
import time
import random
data = np.zeros([360,720],float)
for i in range(0,360):
for j in range(0,720):
if random.random() < 0.9:
data[i,j] = random.randint(20,30)
else:
data[i,j] = random.randint(10,15)
lons = np.arange(-180,180,0.5)
lats = np.arange(-90,90,0.5)
m = Basemap(projection = 'ortho',lon_0 = -95,lat_0 = 75,resolution = 'l')
m.drawcoastlines()
m.drawstates()
m.drawcountries()
lons, lats = np.meshgrid(lons, lats)
x,y = m(lons, lats)
my_cmap = plt.get_cmap('Blues')
my_cmap.set_under('white')
cs = m.pcolormesh(x,y,data,cmap = my_cmap)
m.colorbar(cs, extend = 'min')
plt.show()
我提供了一张图片来说明问题所在: