颜色按类别-散点图

时间:2018-10-15 07:13:49

标签: pandas matplotlib plotly mapbox plotly-dash

我正在尝试按熊猫数据框中列所确定的类别对地图上的点进行分组。以下代码使用plotly和Dash框架构建地图布局和绘图坐标。

for i, row in Comp_data.groupby('Group'):

    data.append({
                "type": "scattermapbox",
                "lat": [hlat],
                "lon": [hlong],
                "name": "Location",
                "mode": "markers",
                "marker": {
                    "symbol": "circle",
                    "color": "grey", <-- needs to be dynamic based on the group
                    "size": 6,
                    "opacity": 0.7
                    }
                }

    )       

有什么想法/建议吗?

1 个答案:

答案 0 :(得分:0)

尝试忽略color属性。该图将为每个数据集提供另一种颜色。

"marker": {
    "symbol": "circle",
    "size": 6,
    "opacity": 0.7
}