Chrome 如何在Python中使用Google Plotly Express

wvt8vs2t  于 2023-05-20  发布在  Go
关注(0)|答案(1)|浏览(188)

我必须改变标记默认的plotly表达的标记一样,谷歌Map,你能给予我的建议,代码
我已经试过这个代码了:def map():

fig = px.scatter_mapbox(df,
                        hover_name=df['kabko'],
                        hover_data=['Jumlah'],
                        lon=df['long'],
                        lat=df['lat'],
                        zoom=5,
                        # size=df['Jumlah'],
                        width=1200,
                        height=900,
                        title="Pesebaran Covid-19 di Indonesia")
fig.update_traces(marker=dict(size=15))
fig.update_layout(mapbox_style='open-street-map')
fig.update_layout(margin={"r": 0, "t": 50, "l": 0, "b": 10})
fig.show()
fig.scatter()

结果是:

0qx6xfy6

0qx6xfy61#

我不确定你的谷歌标记指的是什么,但你可以使用符号作为图形对象标记。并不是following site上的所有标记都可以使用,但是我已经在这个列表中指定了标记。不幸的是,我不能改变颜色。我在多个标记和设置标记符号中使用了自定义符号。

import plotly.graph_objects as go

mapbox_access_token = open("mapbox_api_key.txt").read()

fig = go.Figure(go.Scattermapbox(
        lat=['38.91427','38.91538','38.91458',
             '38.92239','38.93222','38.90842',
             '38.91931','38.93260','38.91368',
             '38.88516','38.921894','38.93206',
             '38.91275'],
        lon=['-77.02827','-77.02013','-77.03155',
             '-77.04227','-77.02854','-77.02419',
             '-77.02518','-77.03304','-77.04509',
             '-76.99656','-77.042438','-77.02821',
             '-77.01239'],
        mode='markers+text',
        marker=go.scattermapbox.Marker(
            size=12,
            symbol='marker',
        ),
        text=["The coffee bar","Bistro Bohem","Black Cat",
             "Snap","Columbia Heights Coffee","Azi's Cafe",
             "Blind Dog Cafe","Le Caprice","Filter",
             "Peregrine","Tryst","The Coupe",
             "Big Bear Cafe"],
    textposition = "bottom right"
    ))

fig.update_layout(
    autosize=True,
    height=450,
    width=900,
    hovermode='closest',
    mapbox=dict(
        accesstoken=mapbox_access_token,
        style='basic',
        bearing=0,
        center=dict(
            lat=38.92,
            lon=-77.04
        ),
        pitch=0,
        zoom=12
    ),
)

fig.show()

相关问题