Hi everyone,
I have a dash app that shows GPS points from around 200 vehicles at 1 minute intervals over 10/20/30 minutes. When I use a single Scattermapbox instance to include all gps points all runs smoothly (by which I mean zooming and panning around the map). However, as soon as I generate a trace per vehicle, effectively creating around 200 traces but not increasing the total number of points displayed, I get significant degradation in performance of general map navigation.
Is that just a limitation of plotting a large number (over 50) traces using scattermapbox or is there some way of improving the performance?
Example code:
import plotly.plotly as py
import plotly.graph_objs as go
import dash
import dash_core_components as dcc
import dash_html_components as html
import numpy as np
# mapbox_access_token = 'TOKEN HERE'
lat = np.random.randint(4500, 4700, size=2000) / 100
lon = np.random.randint(-7400, -7200, size=2000) / 100
lat_lon = np.vstack([lat, lon])
# data = [
# go.Scattermapbox(
# lat=lat,
# lon=lon,
# mode='markers',
# marker=dict(
# size=14
# ),
# text=['Montreal'],
# )
# ]
data = [
go.Scattermapbox(
lat=la_lo[0],
lon=la_lo[1],
mode='markers',
marker=dict(
size=14
),
text=['Montreal'],
) for la_lo in np.split(lat_lon, 200, axis=1)]
layout = go.Layout(
width=1200,
height=700,
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken=mapbox_access_token,
bearing=0,
center=dict(
lat=45,
lon=-73
),
pitch=0,
zoom=5
),
)
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
html.Div(children='''
Dash: A web application framework for Python.
'''),
dcc.Graph(
id='example-graph',
figure={
'data': data,
'layout': layout
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)