【问题标题】:How to add a background color of a colormap in a folium map如何在folium地图中添加颜色图的背景颜色
【发布时间】:2017-12-06 20:00:59
【问题描述】:

我正在使用基于 json 文件创建的 folium 地图。 我使用 branca.colormap 添加了一个 colormap 并且我想添加一个背景颜色,因为生成的颜色图可能有一些颜色和它后面的地图,这会导致可视化问题.

我可以将此颜色图添加到框架中还是仅添加背景颜色?

【问题讨论】:

    标签: python html background-color colormap folium


    【解决方案1】:

    这是一个相当老套的解决方案,但它确实有效:

    通过map_instance.save('map.html')函数打开由folium生成的html文件。

    通过搜索.append("svg") 查找生成传单控件的行

    在其后插入此代码 sn-p,确保变量名称正确(即从代码中的变量复制随机生成的 id)

    color_map_<random_generated_id>.svg.append("rect")
        .attr("width", "100%")
        .attr("height", "100%")
        .attr("fill", "white")
        .attr("opacity", "0.8");
    

    您还可以通过更改 color_map_&lt;random_generated_id&gt;.legend 变量中的传单控制位置属性来定位图例。在我的示例中,我使用L.control({position: 'bottomleft'});

    Image example

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-16
      • 2012-11-25
      • 2019-01-19
      • 2019-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-24
      相关资源
      最近更新 更多