Naas Documentation
Naas.ai
GitHub
Slack Community
What's new?
Search…
Welcome to Naas
😎
Templates
AWS
Airtable
AlphaVantage
Bazimo
Boursorama
Bubble
CCXT
CSV
Canny
Celestrak
Cityfalcon
D-Tale
Dask
Data.gouv.fr
Draft Kings
EM-DAT
Elasticsearch
Excel
FAO
FEC
FTP
GitHub
Gmail
Google Analytics
Google Drive
Google Search
Google Sheets
HTML
Healthchecks
HubSpot
Hugging Face
IFTTT
IMDB
INPI
IUCN
Insee
Instagram
Integromat
Johns Hopkins
Jupyter
Jupyter Notebooks
LinkedIn
Matplotlib
Metrics Store
Microsoft Teams
Microsoft Word
MongoDB
MySQL
NASA
Naas
Naas Auth
Neo
Newsapi
Notion
OpenWeatherMap
OwnCloud
PDF
Pandas
Pillow
Pipedrive
Plaid
Plotly
Create Heatmap
Create Leaderboard stacked
Create Horizontal Barchart
Create Linechart
Create Leaderboard
Create Waterfall chart
Create Vertical Barchart stacked
Create Gantt chart
Create Bubblechart
Create Vertical Barchart group
Create Candlestick
Create Mapchart world
Create Vertical Barchart
PostgresSQL
PyPI
Python
Qonto
Quandl
Reddit
Redshift
Remoteok
Remotive
SAP-HANA
SendGrid
Slack
Snowflake
Societe.com
Spotify
Streamlit
Stripe
Telegram
Thinkific
TikTok
Trello
Twilio
Twitter
WSR
WorldBank
Worldometer
XML
YahooFinance
YouTube
Youtube
ZIP
Zapier
spaCy
Google Analytics
Google Drive
Google Search
Google Sheets
Hugging Face
Johns Hopkins
Jupyter Notebooks
Metrics Store
Microsoft Teams
Microsoft Word
Naas Auth
Elastic Search
Excel 365
🔄
Low-code features
🏎
Low-code drivers
🌎
Community
Essentials
Advanced
Best Practices
FAQ
⚡
Naas manager
🔐
Security
Powered By
GitBook
Create Mapchart world
Tags:
#plotly #chart #worldmap #dataviz #snippet
Author:
Jeremy Ravenel
Input
Import libraries
1
import
naas
2
import
plotly
.
graph_objects
as
go
3
import
pandas
as
pd
Copied!
Variables
1
title
=
"Worldmap"
2
3
# Output paths
4
output_image
=
f"
{
title
}
.png"
5
output_html
=
f"
{
title
}
.html"
Copied!
Get data
Columns :
1.
ISO code of country
2.
Value
To use the built-in countries geometry, provide locations as
three-letter ISO country codes
.
1
df
=
pd
.
read_csv
(
'https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv'
)
2
df
Copied!
Model
Create the plot
1
fig
=
go
.
Figure
()
2
3
fig
=
go
.
Figure
(
data
=
go
.
Choropleth
(
4
locations
=
df
[
'CODE'
],
5
z
=
df
[
'GDP (BILLIONS)'
],
6
text
=
df
[
'COUNTRY'
],
7
colorscale
=
'Blues'
,
8
autocolorscale
=
False
,
9
reversescale
=
True
,
10
marker_line_color
=
'darkgray'
,
11
marker_line_width
=
0.5
,
12
colorbar_tickprefix
=
'#x27;
,
13
colorbar_title
=
'GDP<br>Billions US#x27;
,
14
))
15
16
fig
.
update_layout
(
17
title
=
title
,
18
plot_bgcolor
=
"#ffffff"
,
19
legend_x
=
1
,
20
geo
=
dict
(
21
showframe
=
False
,
22
showcoastlines
=
False
,
23
#projection_type='equirectangular'
24
),
25
dragmode
=
False
,
26
width
=
1200
,
27
height
=
800
,
28
29
)
30
31
config
=
{
'displayModeBar'
:
False
}
32
fig
.
show
(
config
=
config
)
Copied!
Output
Export in PNG and HTML
1
fig
.
write_image
(
output_image
,
width
=
1200
)
2
fig
.
write_html
(
output_html
)
Copied!
Generate shareable assets
1
link_image
=
naas
.
asset
.
add
(
output_image
)
2
link_html
=
naas
.
asset
.
add
(
output_html
,
{
"inline"
:
True
})
3
4
#-> Uncomment the line below to remove your assets
5
# naas.asset.delete(output_image)
6
# naas.asset.delete(output_html)
Copied!
Previous
Create Candlestick
Next
Create Vertical Barchart
Last modified
2mo ago
Copy link
Edit on GitHub
Contents
Input
Model
Output