您可以尝试类似于
that 的东西:
import plotly.plotly as py
import plotly.graph_objs as go
fig = go.Figure(
data=[
go.Scattergeo(
lat=[45.5,43.4,49.13,51.1,53.34,45.24,44.64,48.25,49.89,50.45],
lon=[-73.57,-79.24,-123.06,-114.1,-113.28,-75.43,-63.57,-123.21,-97.13,-104.6],
marker={
"color": ["#bebada","#fdb462","#fb8072","#d9d9d9","#bc80bd","#b3de69","#8dd3c7","#80b1d3","#fccde5","#ffffb3"],
"line": {
"width": 1
},
"size": 10
},
mode="markers+text",
name="",
text=["Montreal","Toronto","Vancouver","Calgary","Edmonton","Ottawa","Halifax","Victoria","Winnepeg","Regina"],
textfont={
"color": ["#bebada","#fdb462","#fb8072","#d9d9d9","#bc80bd","#b3de69","#8dd3c7","#80b1d3","#fccde5","#ffffb3"],
"family": ["Arial, sans-serif","Balto, sans-serif","Courier New, monospace","Droid Sans, sans-serif","Droid Serif, serif","Droid Sans Mono, sans-serif","Gravitas One, cursive","Old Standard TT, serif","Open Sans, sans-serif","PT Sans Narrow, sans-serif","Raleway, sans-serif","Times New Roman, Times, serif"],
"size": [22,21,20,19,18,17,16,15,14,13]
},
textposition=["top center","middle left","top center","bottom center","top right","middle left","bottom right","bottom left","top right","top right"]
)
],
layout={
"title": "Canadian cities",
"geo": {
"lataxis": {
"range": [40, 70]
},
"lonaxis": {
"range": [-130, -55]
},
"scope": "north america"
}
}
)
plot_url = py.plot(fig, filename='Canadian Cities')
抱歉,您没有提供要翻译的英文文本。请提供文本以便我能够为您提供帮助。
import pandas as pd
lat = 47.8388
lon = 35.1396
df = pd.DataFrame({'lat': lat + np.random.normal(1,0.2,10),'lon': lon + np.random.normal(1,0.2,10)})
df = df.round(4)
pd.options.display.float_format = '{:.4f}'.format
df['text'] = df.lat.astype(str) + ', ' + df.lon.astype(str)
print(df)
ax = df.plot(x='lat', y='lon', kind='scatter')
y_shift = (df.lon.max()-df.lon.min())/len(df)
[ax.annotate(tup[2], xy=tup[:2], xytext=(tup[0], tup[1]))
for tup in df.itertuples(index=False)]
plt.show()
我把坐标作为注释的文本放置...