我试图显示一个contourf plot
,正如你在一个对开本映射的代码片段中看到的那样
我可以很好地看到填充的等高线图。另外,我在这一行使用branca
添加了一个颜色完全相同的颜色栏:
bmap = branca.colormap.LinearColormap(colorl, vmin=levs[0],
vmax=levs[-1]).to_step(len(levs),index=levs)
geojsonf = geojsoncontour.contourf_to_geojson(
contourf=pcontf,
min_angle_deg=3.0,
ndigits=5,
stroke_width=1,
fill_opacity=0.9)
正如您在输出图像中看到的,颜色不匹配
我怀疑我用于等高线图的不透明度可能在这里起作用,但更改不透明度并不能使其更好
我也试着用同样的颜色做圆圈标记(这里没有显示),但仍然没有成功。我无法使pyplot颜色匹配
非常感谢您的任何建议。还有没有更好的方法来完成同样的任务?我基本上有一个2D NumPy数组,在一个重新投影的lat-lon网格上,它的值范围为-50 to 50
。我需要能够显示阴影轮廓和相关的酒吧价值观
fig = plt.figure(figsize=[10, 15], dpi=None)
ax = fig.subplots()
jet =plt.get_cmap('jet')
clevs= np.array(levs)
cnorm = plt.Normalize(vmin=levs[0],vmax=levs[-1])
clevels = [levs[0]] + list(0.5*(clevs[1:]+clevs[:-1])) + [levs[-1]]
colors=jet(cnorm(clevels))
colorsm = color.ListedColormap(colors)
pcontf = ax.contourf(lons,lats,data,levels=levs,cmap=colorsm)
mapa = folium.Map([np.mean(lats), np.mean(lons)], zoom_start=10,tiles='Stamen Terrain')
colorl = []
for i,val in enumerate(colors):
carr= colors[i-1]
ccol = (carr[1],carr[2],carr[3])
colorl.insert(i,ccol)
bmap = branca.colormap.LinearColormap(colorl, vmin=levs[0],
vmax=levs[-1]).to_step(len(levs),index=levs)
geojsonf = geojsoncontour.contourf_to_geojson(
contourf=pcontf,
min_angle_deg=3.0,
ndigits=5,
stroke_width=1,
fill_opacity=0.9)
folium.GeoJson(
geojsonf,
style_function=lambda x: {
'color': x['properties']['stroke'],
'weight': x['properties']['stroke-width'],
'fillColor': x['properties']['fill'],
'opacity': 0.9,
}).add_to(mapa)
bmap.add_to(mapa)
目前没有回答
相关问题 更多 >
编程相关推荐