Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To display a choropleth map on Jupyter Notebook using Plotly Express, you can follow these steps:

  1. Import necessary libraries:
import plotly.express as px
import pandas as pd
  1. Load data in a Pandas DataFrame:
df = pd.read_csv("path_to_csv_file.csv")
  1. Choose a mapbox token to use:
px.set_mapbox_access_token('your_mapbox_token')
  1. Create a choropleth map using Plotly Express and display it:
fig = px.choropleth(df, locations="location_column_name", color="data_column_name",
                    color_continuous_scale=px.colors.sequential.Plasma)
fig.show()

In this example, replace "locationcolumnname" with the name of the column in your DataFrame that contains the locations (e.g. country names or ISO codes), and "datacolumnname" with the name of the column that contains the data you want to visualize on the map. You can also adjust the color scale and any other parameters to customize the visualization to your needs.

Note that for the map to display in Jupyter Notebook, you will need to be running the notebook locally and have a live internet connection (as the map relies on data from the Mapbox API).