首页 > 解决方案 > folium 地图中的非线性颜色图

问题描述

我正在folium使用对数比例阴影在地图上绘制彩色区域。使用自定义颜色图,区域颜色似乎没问题。但是,当添加到地图图例中时,颜色图仍然看起来是线性的:

在传单地图图例中仍然是线性的

有没有办法将它绘制为等宽的彩色矩形,下面有文本值?

import numpy as np, branca, folium
m = folium.Map()
colormap = branca.colormap.LinearColormap(colors=['blue', 'green', 'yellow', 'orange', 'red'],
                                          index = np.round(np.exp(np.linspace(0, 9, 5))),
                                          vmin = 0, vmax = np.exp(9),
           ).to_step(n=6, index=np.round(np.exp(np.linspace(0, 9, 6))))
colormap.add_to(m)

标签: pythonleafletcolormapfoliumchoropleth

解决方案


推荐阅读