Skip to content

Instantly share code, notes, and snippets.

@fdrcslv
Last active January 10, 2019 09:50
Show Gist options
  • Save fdrcslv/623abbe3c6b98a04263a3c71a448c23e to your computer and use it in GitHub Desktop.
Save fdrcslv/623abbe3c6b98a04263a3c71a448c23e to your computer and use it in GitHub Desktop.
test_map.py
import plotly.graph_objs as go
import plotly.io as pio
#orca serve
if __name__ == '__main__':
pio.orca.config.port = 8005
data = [
go.Scattermapbox(
lat=['45.5017'],
lon=['-73.5673'],
mode='markers',
marker=dict(
size=14
),
text=['Montreal'],
)
]
layout = go.Layout(
autosize=True,
hovermode='closest',
mapbox=dict(
accesstoken='pk.eyJ1IjoiY29sb3VyZWUiLCJhIjoiY2phbWp4cnkwNDI0dDMzcjFwY2hybGN4MiJ9.Zke-1vfMlfaCvGTICQwxDw',
bearing=0,
center=dict(
lat=45,
lon=-73
),
pitch=0,
zoom=5
),
)
fig = dict(data=data, layout=layout)
#write json with plotly.io
pio.write_json(fig, 'figure.json', pretty=True)
pio.orca.config.mapbox_access_token = 'pk.eyJ1IjoiY29sb3VyZWUiLCJhIjoiY2phbWp4cnkwNDI0dDMzcjFwY2hybGN4MiJ9.Zke-1vfMlfaCvGTICQwxDw'
pio.write_image(fig, 'figure.png')
#TERMINAL
# orca graph figure.json --mapbox-access-token pk.eyJ1IjoiY29sb3VyZWUiLCJhIjoiY2phbWp4cnkwNDI0dDMzcjFwY2hybGN4MiJ9.Zke-1vfMlfaCvGTICQwxDw -o figure.png --verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment