Skip to content

This script creates an animated choropleth map using the Plotly Express library, which shows how the GDP per capita of different countries evolves over the years.

Notifications You must be signed in to change notification settings

SidneyTeodoroJr/choropleth_map_GDP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Choropleth Map GDP


choropleth map


This Python script uses the Plotly Express library to create an animated choropleth map that displays the per capita Gross Domestic Product (GDP) of different countries over the years. Data is read from an online CSV file and the map is customized with a title and light gray background before being displayed on the screen.

1 - Importing Libraries:

. import plotly.express as px: Imports the Plotly Express library, which is used to create interactive plots, including choropleth maps.

. import pandas as pd: Imports the Pandas library, which is used for data manipulation and analysis.

2 - Data Import:

The script reads data from a CSV file hosted on GitHub. The file contains data relating to GDP per capita for various countries over time, as well as information about the countries such as the ISO code and country name. The data is read into a Pandas DataFrame called data.

3 - Creation of the Choroplectic Map:

. px.choropleth: This Plotly Express function is used to create a coropleth map.

. data: The DataFrame that contains the data.

. locations: The column in the DataFrame that contains ISO country codes, used to map geographic regions.

. color: The column in the DataFrame that contains the values ​​that determine the color of the map (in this case, GDP per capita).

. hover_name: The column in the DataFrame that provides additional information displayed when the mouse is placed over a region.

. projection: The geographic projection used for the map.

. animation_frame: The column in the DataFrame that determines the animation over time (in this case, the year).

. title: The title of the map.

4 - Layout Customization:

fig.update_layout: This line of code is used to update and customize the map layout. In this case, the map background color is set to light gray.

5 - Map Display:

fig.show(): Displays the interactive map on the screen.

Contributions

Contributions are welcome! If you want to improve facial detection, add new features, or fix issues, feel free to submit a pull request.
If you encounter any problems or have any suggestions for improvement, you can contact me through my profile on GitHub or through my social networks listed below.



About

This script creates an animated choropleth map using the Plotly Express library, which shows how the GDP per capita of different countries evolves over the years.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages