python-visualization / python-visualization/branca

Feature request: colormap with background

Đang mở
#124 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement
Ngôn ngữ chính
Python
Star
134
Fork
69
Merge trung bình
1 giờ 10 phút
Pull request đã merge (30 ngày)
1

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách kiểm tra các lớp branca.colormap và HTML colormap được tạo ra mà ví dụ sử dụng. Theo dõi cách colormap được kết xuất và xác định vị trí có thể biểu diễn một hình chữ nhật nền tùy chọn; được xem là hoàn tất khi ví dụ hiện có hỗ trợ chọn màu nền mà không thay đổi ánh xạ màu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
data-visualization
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.