加拿大 python_加拿大的Scattergeo在python中使用plotly

您需要在layout中的geo字典中指定附加参数lataxis和{}(基于this)。在这种情况下,locationmode和{}这样的参数对我没有帮助。在

代码:# import all the necessaries libraries

from plotly import tools

import plotly.offline as py

import plotly.graph_objs as go

import pandas as pd

# your df

stores_info_df = pd.DataFrame({'LONGITUDE':[-60,-80,-100,-120],

'LATITUDE':[50,51,53,54],

'STRATEGY':['One','Two','Three','Four']})

# your function

def visualize_geo_store_canada(stores_info_df,

fig_name='store_strategy_Canada_map', title = 'Stores Strategy'):

data = [ dict(

type = 'scattergeo',

##### WHAT TO REPLACE? ########

#locationmode = 'Canada',

###############################

lon = stores_info_df['LONGITUDE'],

lat = stores_info_df['LATITUDE'],

text = stores_info_df['STRATEGY'],

mode = 'markers',

marker = dict(

colorscale= 'Jet',

color = stores_info_df['STRATEGY'],

colorbar = dict(

title = 'Strategy',

titleside = 'top',

tickmode = 'array',

)

))]

layout = dict(

title = title,

geo = dict(

##### WHAT TO REPLACE? ########

#scope='north-america',

###############################

showland = True,

# Add coordinates limits on a map

lataxis = dict(range=[40,70]),

lonaxis = dict(range=[-130,-55]),

landcolor = "rgb(250, 250, 250)",

subunitcolor = "rgb(217, 217, 217)",

countrycolor = "rgb(217, 217, 217)",

countrywidth = 0.5,

subunitwidth = 0.5

),

)

fig = dict(data=data, layout=layout)

py.plot(fig, validate=False)

# plot a plot

visualize_geo_store_canada(stores_info_df)

输出:

a79760bc4ae79400310c58532ec39fed.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值