在Plotly中,如果需要在地图上添加箭头图层,则需要使用ff.create_quiver函数。要将它添加到Scattermapbox中的一个跟踪中,可以按照以下步骤进行:
import plotly.graph_objs as go from plotly.subplots import make_subplots import numpy as np import plotly.figure_factory as ff
fig = go.Figure(go.Scattermapbox())
x, y = np.meshgrid(np.arange(0, 10), np.arange(0, 10))
u = np.ones((10, 10)) v = np.zeros((10, 10))
quiver = ff.create_quiver(x, y, u, v, arrow_scale=0.4, name='quiver', line=dict(width=1))
fig.add_trace(quiver.data[0])
fig.update_layout( mapbox=dict( center=go.layout.mapbox.Center(lat=48.8534, lon=2.3488), zoom=12, ), )
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
通过以上过程,就可以在地图上展示箭头图层了。