<jupyter_start><jupyter_text>Plotly - Create a World Map **Tags:** plotly chart worldmap dataviz  Input  Import libraries<jupyter_code>import naas
import plotly.graph_objects as go
import pandas as pd<jupyter_output><empty_output><jupyter_text>Variables<jupyter_code>title = "Worldmap"

# Output paths
output_image = f"{title}.png"
output_html = f"{title}.html"<jupyter_output><empty_output><jupyter_text>Get dataColumns :1. ISO code of country    2. Value To use the built-in countries geometry, provide locations as [three-letter ISO country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3).<jupyter_code>df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_world_gdp_with_codes.csv')
df<jupyter_output><empty_output><jupyter_text>Model  Create the plot<jupyter_code>fig = go.Figure()

config = {'displayModeBar': False}

fig = go.Figure(data=go.Choropleth(
    locations = df['CODE'],
    z = df['GDP (BILLIONS)'],
    text = df['COUNTRY'],
    colorscale = 'Blues',
    autocolorscale=False,
    reversescale=True,
    marker_line_color='darkgray',
    marker_line_width=0.5,
    colorbar_tickprefix = '$',
    colorbar_title = 'GDP<br>Billions US$',
))

fig.update_layout(
    title=title ,
    plot_bgcolor="#ffffff",
    legend_x=1,
    geo=dict(
        showframe=False,
        showcoastlines=False,
        #projection_type='equirectangular'
    ),
    dragmode= False,
    #width=800,
    height=600,

)
fig.show(config=config)<jupyter_output><empty_output><jupyter_text>Output  Export in PNG and HTML<jupyter_code>fig.write_image(output_image, width=1200)
fig.write_html(output_html)<jupyter_output><empty_output><jupyter_text>Generate shareable assets<jupyter_code>link_image = naas.asset.add(output_image)
link_html = naas.asset.add(output_html, {"inline":True})<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12656165127648017, 'fraction_numerical': 0.013579576317218903, 'mean_word_length': 5.747252747252747, 'pattern_counts': {'":': 1, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '598742', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 687, 'n_tokens_neox': 664, 'n_words': 104, 'path': 'Plotly/Plotly_Mapchart_world.ipynb', 'repo_name': 'vivard/awesome-notebooks', 'size': '1841'}