python-visualization / python-visualization/branca

Feature request: colormap with background

未关闭
#124 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
Python
星标
134
派生
69
平均合并
1 小时 10 分钟
30 天内合并 PR
1

描述

Code Sample
import folium
import pandas as pd
import folium.plugins

import branca
import branca.colormap as cm

data = [
    [33.823400, -118.12194, 99.23],
    [33.823500, -118.12294, 95.23],
    [33.823600, -118.12394, 91.23],
    [33.823700, -118.12494, 90.00]
]

df = pd.DataFrame(data, columns=['latitude','longitude','data'])

x_start = (df['latitude'].max() + df['latitude'].min()) / 2
y_start = (df['longitude'].max() + df['longitude'].min()) / 2
start_coord = (x_start, y_start)


colormap = cm.LinearColormap(colors=['red','lightblue'],
                             index=[df['data'].min(),df['data'].max()],
                             vmin=df['data'].min(),vmax=df['data'].max())

colormap.caption = 'Data [units]'

map = folium.Map(location=start_coord, zoom_start=12)


lat = list(df.latitude)
lon = list(df.longitude)
dat = list(df.data)


for loc, p in zip(zip(lat, lon), dat):
    folium.Circle(
        location=loc,
        radius=10,
        fill=True,
        color=colormap(p),
        fill_opacity=0.7
    ).add_to(map)

map.add_child(colormap)
map.save('index.html')

Problem description

Code above creates colored points, and displays a colormap to show what data value each color corresponds to. This is great but it would be even better if a background colour could be selected. This slightly hacky work-around does exactly what I want:
https://stackoverflow.com/a/50427006/4988601

I'd be happy to try and plumb this into folium itself if a few people show some interest in this feature (I'm fairly new to folium so any pointers on what methods/classes I'd need to poke around in would be appreciated).

Expected Output

Colormap with an optional background color rectangle to help it stand out.

Output of folium.__version__

0.10.0

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先检查 branca.colormap 类以及示例使用的生成 colormap HTML。跟踪 colormap 的渲染方式,并确定可以在哪里表示可选的背景矩形;当现有示例支持选择背景色且不改变颜色映射时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data-visualization
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。