Hi Jon,
first of all, thanks for your reply, appreciate man
Please find below my full example :
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.offline as offline
import pandas as pd
mapbox_access_token = 'XXXXXX'
#Reading files
df_locations = pd.read_csv("C:/Users/Vicky/PycharmProjects/QC_map_sols/data/quebecDL1.csv")
df_locations.head()
df_flight_paths = pd.read_csv("C:/Users/Vicky/PycharmProjects/QC_map_sols/data/quebecDL1D1_exactsol.csv")
df_flight_paths.head()
#Marker part#
airports = [go.Scattergeo(
locationmode = 'USA-states',
lon = df_locations['long'],
lat = df_locations['lat'],
hoverinfo = 'text',
text = df_locations['loc'],
mode = 'markers',
marker = go.scattergeo.Marker(
size = 2,
color = 'rgb(255, 0, 0)',
line = go.scattergeo.marker.Line(
width = 3,
color = 'rgba(68, 68, 68, 0)'
)
))]
#Reading data from my csv files
flight_paths = []
for i in range(len(df_flight_paths)):
flight_paths.append(
go.Scattergeo(
locationmode = 'USA-states',
lon = [df_flight_paths['start_lon'][i], df_flight_paths['end_lon'][i]],
lat = [df_flight_paths['start_lat'][i], df_flight_paths['end_lat'][i]],
mode = 'lines',
line = go.scattergeo.Line(
width = 1,
color = 'red',
),
opacity = float(df_flight_paths['cnt'][i]) / float(df_flight_paths['cnt'].max()),
)
)
layout = go.Layout(
autosize=True,
hovermode='closest',
title = go.layout.Title(
text = 'Solution for QC_DL1'
),
geo = go.layout.Geo(
scope = 'north america',
projection = go.layout.geo.Projection(type = 'azimuthal equal area'),
showland = True,
landcolor = 'rgb(243, 243, 243)',
countrycolor = 'rgb(204, 204, 204)',
),
###ZOOM part, but doesn't work ###
mapbox=dict(
accesstoken=mapbox_access_token,
bearing=0,
center=dict( #Looks like only this parameter is now used
lat=45.5016889, #el inicio!
lon=-80.56725599999999
),
pitch=0,
zoom=7.8,
),
showlegend = False,
)
print(layout)
fig = go.Figure(data = flight_paths + airports, layout = layout, )
#py.iplot(fig, filename = 'd3-flight-paths')
offline.plot(fig, filename='quebecDL1D1_exactsol'+'.html')
Now to give you some ideas about what my file :
QuebecDL1.csv :
loc |
lat |
long |
color |
size |
mark |
Depot1 |
45.108 |
-72.616 |
blue |
20 |
1 |
Depot2 |
45.497 |
-73.486 |
blue |
20 |
1 |
IL1 |
45.285 |
-72.973 |
green |
15 |
2 |
C1 |
45.208 |
-72.715 |
green |
7 |
0 |
C2 |
45.209 |
-72.765 |
green |
7 |
0 |
C3 |
45.251 |
-74.13 |
green |
7 |
0 |
C4 |
45.333 |
-73.27 |
green |
7 |
0 |
C5 |
45.346 |
-73.766 |
green |
7 |
0 |
C6 |
45.41 |
-72.722 |
green |
7 |
0 |
C7 |
45.478 |
-73.465 |
green |
7 |
0 |
C8 |
45.492 |
-73.403 |
green |
7 |
0 |
C9 |
45.499 |
-73.487 |
green |
7 |
0 |
C10 |
45.527 |
-73.483 |
green |
7 |
0 |
C11 |
45.538 |
-73.457 |
green |
7 |
0 |
C12 |
45.538 |
-73.458 |
green |
7 |
0 |
C13 |
45.593 |
-73.337 |
green |
7 |
0 |
C14 |
45.603 |
-73.452 |
green |
7 |
0 |
C15 |
45.634 |
-72.961 |
green |
7 |
0 |
C16 |
45.68 |
-73.438 |
green |
7 |
0 |
C17 |
45.773 |
-73.352 |
green |
7 |
0 |
C18 |
45.854 |
-73.243 |
green |
7 |
0 |
QuebecDL1D1_exactsol :
start_lat |
start_lon |
end_lat |
end_lon |
airport1 |
airport2 |
cnt |
45.108 |
-72.616 |
45.208 |
-72.715 |
dl1 |
c1 |
444 |
45.208 |
-72.715 |
45.333 |
-73.27 |
c1 |
c4 |
166 |
45.333 |
-73.27 |
45.41 |
-72.722 |
c4 |
c7 |
56 |
start_lat |
start_lon |
end_lat |
end_lon |
airport1 |
airport2 |
cnt |
45.108 |
-72.616 |
45.208 |
-72.715 |
dl1 |
c1 |
444 |
45.208 |
-72.715 |
45.333 |
-73.27 |
c1 |
c4 |
166 |
45.333 |
-73.27 |
45.41 |
-72.722 |
c4 |
c7 |
56 |
To view the help of layout.Mapbox
class use help(plotly.graph_objs.layout.Mapbox)
.
Yes, this is my point (see last screenshot), running that I see only 2 arguments and I donât see any zoom mentionned as expectedâŚ
No issue running this code, only that zoom is not correctly applied as it should :
C:\Users\Vicky\Anaconda3\python.exe C:/Users/Vicky/PycharmProjects/QC_map_sols/main.py
Layout({
âautosizeâ: True,
âgeoâ: {âcountrycolorâ: ârgb(204, 204, 204)â,
âlandcolorâ: ârgb(243, 243, 243)â,
âprojectionâ: {âtypeâ: âazimuthal equal areaâ},
âscopeâ: ânorth americaâ,
âshowlandâ: True},
âhovermodeâ: âclosestâ,
âmapboxâ: {âaccesstokenâ: (âpk.eyJ1IjoidmljdG9yaWFyZWJpbGxâ ⌠âNWxoIn0.OOq_jBhv6jauT58SVb9iyAâ),
âbearingâ: 0,
âcenterâ: {âlatâ: 45.5016889, âlonâ: -80.56725599999999},
âpitchâ: 0,
âzoomâ: 7.8},
âshowlegendâ: False,
âtitleâ: {âtextâ: âSolution for QC_DL1â}
})
Process finished with exit code 0
Best regards,
Robin.