【发布时间】:2016-03-02 22:36:16
【问题描述】:
以here 的示例为基础,我想在地图上用不同的 alpha 值和不同的面颜色绘制点(我计划更新它们)。但是,alpha 值似乎没有更新(它们似乎一开始也被忽略了)。
首先,根据示例创建地图并绘制三个点:
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
map = Basemap(projection='merc', lat_0 = 57, lon_0 = -135,
resolution = 'h', area_thresh = 0.1,
llcrnrlon=-136.25, llcrnrlat=56.0,
urcrnrlon=-134.25, urcrnrlat=57.75)
map.drawcoastlines()
map.drawcountries()
map.fillcontinents(color = 'lightgray', zorder = 0)
map.drawmapboundary()
lons = [-135.3318, -134.8331, -134.6572]
lats = [57.0799, 57.0894, 56.2399]
x,y = map(lons, lats)
pts = map.scatter(x, y, c ='r', marker = 'o', s = 80, alpha = 1.0)
然后用新的 rgba 值更新 facecolors。
pts.set_facecolor([(0.7, 0.3, 0.3, 1.0), (1, 0.0, 1, 0.5), (1.0, 1.0, 0.2, 0.2)])
fig.canvas.draw()
颜色更新,但 alpha 值未正确绘制。我也尝试过使用pts.set_alpha,但这不允许列表作为参数。
【问题讨论】:
标签: python matplotlib alpha matplotlib-basemap