1 | initial version |
To display a choropleth map on Jupyter Notebook using Plotly Express, you can follow these steps:
import plotly.express as px
import pandas as pd
df = pd.read_csv("path_to_csv_file.csv")
px.set_mapbox_access_token('your_mapbox_token')
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).