A Python data visualization analysis of world development indicators of China
Tutorial
Chinese world development indicators analysis using LightningChart Python.
Introduction to World Development Indicators
World Development Indicators (WDI) are essential metrics that help us understand global socio-economic and environmental progress. These indicators are used by governments, policymakers, and researchers to monitor and assess development trends. In this tutorial, we leverage LightningChart—a powerful data visualization tool—to explore, analyze, and communicate complex patterns in WDI data. LightningChart’s real-time rendering and interactive features make it ideal for handling large datasets like WDI, offering clear insights through advanced visualizations.
Users of World Development Indicators
- Governments: To shape economic and social policies.
- Researchers and Analysts: For in-depth global studies.
International Organizations: Including the World Bank and UN, to measure progress toward global goals such as the Sustainable Development Goals (SDGs).
LightningChart Python
LightningChart Python is a high-performance data visualization library known for efficiently handling large datasets. LightningChart Python was instrumental in rendering multiple environmental parameters from NOAA’s API and simulating real-time data playback in this project.
Its flexibility allowed for the seamless integration of various chart types, such as line charts with stacked Y-axes, which visualized wind speeds, water levels, tide predictions, and temperature variations. LightningChart Python’s powerful rendering capabilities ensured smooth and responsive updates, even when processing multiple parameters in simulated real-time.
In this project, we leverage several of LightningChart Python’s chart types to visualize the trends and disparities in electricity access:
- Line Chart for GDP and Inflation: This chart displays China’s GDP growth and inflation over time, providing a clear view of economic stability and fluctuations.
- Polar Chart for Sectoral Indicators: Using a Polar Chart, we compare China’s sector-specific indicators (e.g., Finance, Agriculture) against the world averages, highlighting where China stands in the global context.
- 3D Surface Chart for GDP, Inflation, and Money Supply: This interactive 3D chart demonstrates the relationship between GDP growth, inflation, and money supply over time, offering an advanced perspective on economic dynamics.
Key Features of LightningChart for WDI Analysis
- High Performance and Speed: LightningChart’s graphics engine is built for speed, capable of rendering millions of data points in real time without sacrificing quality or responsiveness. This capability is essential when visualizing extensive datasets like WDI, where interactive exploration of multiple indicators over decades is required.
- Customization and Flexibility: The library offers extensive customization options. Users can modify axes, colors, chart types, and data labels, enabling them to create visualizations tailored to specific analysis needs. For example, it’s easy to differentiate between cumulative indicators and growth metrics by customizing line styles and colors.
- Interactive and Dynamic Visualizations: LightningChart supports interactive features such as tooltips, zooming, and real-time updates. These interactions are especially beneficial for analyzing WDI data, as users can drill down into country-specific trends or explore global comparisons in detail.
- 3D and Complex Plotting Capabilities: Unlike many charting tools, LightningChart provides sophisticated 3D plotting options, such as surface and volumetric charts. For economic data analysis, 3D charts help illustrate complex relationships between multiple indicators, such as the interaction between GDP growth, inflation, and monetary supply.
- Comprehensive Chart Variety: From basic bar and line charts to advanced polar and pie charts, LightningChart supports a wide variety of chart types. This variety allows users to select the most suitable chart to represent specific WDI indicators, such as using pie charts for economic sector distributions or polar charts for comparing global trends.
Setting Up Python Environment
To begin working on this project, it’s necessary to install the required libraries, including Pandas and LightningChart Python. You can do this by following the steps below:
- First, you need to install Python: Download and install the latest version of Python from the official Python website.
- Second, you need to Install Pandas and LightningChart:
Use the pip package manager to install the necessary libraries by running these commands:
pip install lightningchart
pip install pandas numpy
To analyze and visualize the data, we’ll use a combination of libraries such as:
- Pandas: For data manipulation and analysis.
- NumPy: For numerical operations.
- LightningChart: A high-performance charting library for data visualization.
import pandas as pd
import lightningchart as lc
import numpy as np
Data Loading and Preprocessing
First, we load the dataset and clean it.
# Load the dataset
data = pd.read_csv(' allcleanData_filled.csv')
# Clean the dataset (dropping unnecessary columns)
data_cleaned = data.drop(columns=['Code'])
Visualizing Data with LightningChart Python
Using LightningChart’s robust features, we create various visualizations to uncover insights within WDI data:
Cumulative Financial Indicators (Line Chart)
This code visualizes China’s cumulative financial indicators as a percentage of GDP over time, including Broad Money Supply, Private Sector Assets, Private Sector Capital Assets, and Market Trade Value. It shows trends in these indicators, reflecting China’s financial sector development and economic shifts over the years.
# Filter China's cumulative indicators and create a line chart
cumulative_indicators_codes = ['FM.LBL.BMNY.GD.ZS', 'FS.AST.PRVT.GD.ZS', 'FD.AST.PRVT.GD.ZS', 'CM.MKT.TRAD.GD.ZS']
china_cumulative_data = transformed_data[(transformed_data['Country Name'] == 'China') & (transformed_data['Indicator Code'].isin(cumulative_indicators_codes))]
# Pivot data for easier plotting
china_cumulative_pivot = china_cumulative_data.pivot(index='Year', columns='Indicator Name', values='Value')
# Create ChartXY for cumulative indicators
chart = lc.ChartXY(title="Cumulative Indicators for China as Percentage of GDP Over Time", theme=lc.Themes.Light)
chart.get_default_x_axis().set_title("Year")
chart.get_default_y_axis().set_title("Percentage of GDP (%)")
# Plot each indicator series
for column in china_cumulative_pivot.columns:
series = chart.add_line_series().set_name(column).set_line_thickness(3)
series.add(x=china_cumulative_pivot.index.tolist(), y=china_cumulative_pivot[column].fillna(0).tolist())
series.set_highlight(True).set_cursor_enabled(True)
# Add legend and display chart
chart.add_legend(data=chart).set_position(x=35, y=80)
chart.open()
Comparing Economic Growth, Inflation, and Financial Indicators in China (Combined Line Chart)
This code visualizes China’s GDP Growth, Inflation (solid lines), and Cumulative Financial Indicators (dashed lines) over time, showing economic trends and financial development.
# Define and filter data for growth/inflation and cumulative indicators for China
growth_inflation_codes = ['FP.CPI.TOTL.ZG', 'NY.GDP.DEFL.KD.ZG', 'NY.GDP.MKTP.KD.ZG']
cumulative_indicators_codes = ['FM.LBL.BMNY.GD.ZS', 'FS.AST.PRVT.GD.ZS', 'FD.AST.PRVT.GD.ZS', 'CM.MKT.TRAD.GD.ZS']
china_growth_inflation_long = china_data[china_data['Indicator Code'].isin(growth_inflation_codes)].melt(id_vars=['Country Name', 'Indicator Code'], value_vars=available_years, var_name='Year', value_name='Value')
china_cumulative_long = china_data[china_data['Indicator Code'].isin(cumulative_indicators_codes)].melt(id_vars=['Country Name', 'Indicator Code'], value_vars=available_years, var_name='Year', value_name='Value')
# Create and configure ChartXY for comparison of growth, inflation, and cumulative indicators
chart = lc.ChartXY(title="Comparison of China's GDP Growth, Inflation, and Cumulative Indicators Over Time", theme=lc.Themes.Light)
chart.get_default_x_axis().set_title("Year")
chart.get_default_y_axis().set_title("Percentage (%)")
# Plot growth/inflation indicators with solid lines and cumulative indicators with dashed lines
for indicator in growth_inflation_codes:
series = chart.add_line_series().set_name(f"Growth/Inflation - {indicator}")
indicator_data = china_growth_inflation_long[china_growth_inflation_long['Indicator Code'] == indicator]
series.add(x=indicator_data['Year'].tolist(), y=indicator_data['Value'].fillna(0).tolist())
for indicator in cumulative_indicators_codes:
series = chart.add_line_series().set_name(f"Cumulative - {indicator}").set_line_thickness(3).set_dashed(pattern="Dashed")
indicator_data = china_cumulative_long[china_cumulative_long['Indicator Code'] == indicator]
series.add(x=indicator_data['Year'].tolist(), y=indicator_data['Value'].fillna(0).tolist())
# Add legend and display chart
chart.add_legend(data=chart).set_position(x=25, y=80)
chart.open()
3D Visualization of Economic Indicators: GDP Growth, Inflation, and Money Supply
This code creates a 3D surface chart for China, showing GDP Growth, Inflation, and Broad Money Supply. It uses a smooth surface with color intensity to highlight trends and relationships among these indicators over time:
# Filter data for China and select relevant indicators for GDP Growth, Inflation, and Broad Money Supply
three_d_data = china_data[china_data['Indicator Code'].isin(['NY.GDP.MKTP.KD.ZG', 'FP.CPI.TOTL.ZG', 'FM.LBL.BMNY.GD.ZS'])]
three_d_long = three_d_data.melt(id_vars=['Country Name', 'Indicator Code'], value_vars=available_years, var_name='Year', value_name='Value')
# Prepare data for 3D surface plot
three_d_pivot = three_d_long.pivot_table(index='Year', columns='Indicator Code', values='Value').dropna()
X, Y = np.meshgrid(np.linspace(three_d_pivot['NY.GDP.MKTP.KD.ZG'].min(), three_d_pivot['NY.GDP.MKTP.KD.ZG'].max(), 100),
np.linspace(three_d_pivot['FP.CPI.TOTL.ZG'].min(), three_d_pivot['FP.CPI.TOTL.ZG'].max(), 100))
Z = griddata((three_d_pivot['NY.GDP.MKTP.KD.ZG'], three_d_pivot['FP.CPI.TOTL.ZG']), three_d_pivot['FM.LBL.BMNY.GD.ZS'], (X, Y), method='cubic')
Z[np.isnan(Z)] = np.nanmean(three_d_pivot['FM.LBL.BMNY.GD.ZS'])
# Create 3D surface chart with Viridis color scheme and Matplotlib-style background
chart = lc.Chart3D(theme=lc.Themes.Light, title='3D Surface of GDP Growth, Inflation, and Broad Money Supply')
surface_series = chart.add_surface_grid_series(columns=Z.shape[1], rows=Z.shape[0]).set_start(x=X.min(), z=Y.min()).set_end(x=X.max(), z=Y.max())
surface_series.invalidate_height_map(Z.tolist()).invalidate_intensity_values(Z.tolist())
surface_series.set_color_shading_style(phong_shading=True, specular_reflection=0.3).set_palette_colors(
steps=[{"value": -200, "color": lc.Color(68, 1, 84)}, {"value": 200, "color": lc.Color(253, 231, 37)}],
look_up_property='value', interpolate=True
)
chart.get_default_x_axis().set_title('GDP Growth (annual %)')
chart.get_default_y_axis().set_title('Broad Money Supply (% of GDP)')
chart.get_default_z_axis().set_title('Inflation (Consumer Prices %)')
chart.set_background_color(lc.Color(255, 255, 255))
chart.add_legend(data=surface_series)
chart.open()
China’s Economic Composition in 2022 (Pie Chart)
This code generates a pie chart showing China’s economic indicators for 2022 as percentages of GDP. The chart highlights each indicator’s contribution, with slices sorted from highest to lowest, offering a clear view of China’s economic composition for that year.
# Filter and sort China's 2022 data by percentage values
china_data_2022_sorted = data[(data['Country Name'] == 'China') & (data['2022'].notna())][['Indicator Code', '2022']].sort_values(by='2022', ascending=False)
data_for_chart = [{'name': row['Indicator Code'], 'value': row['2022']} for _, row in china_data_2022_sorted.iterrows()]
# Create and configure PieChart for China's indicators in 2022
chart = lc.PieChart(title="China's Indicators in 2022 (as % of GDP)", theme=lc.Themes.White)
chart.set_slice_stroke(color=lc.Color('white'), thickness=1).add_slices(data_for_chart).add_legend(data=chart)
chart.open()
Sectoral Contributions to China’s GDP (Bar Chart)
This code creates a bar chart displaying various economic indicator groups for China in 2022, such as Agriculture, Finance, Natural Resources, and more. Each group’s bar represents the total percentage of GDP for its indicators, offering a quick comparison of the economic contributions by sector. Bars are sorted in descending order for clarity.
# Define indicator groups and calculate total values for each group in China for 2022
indicator_groups = {'Agriculture', 'Finance', 'Natural', 'Trade', 'Investment', 'Consumption', 'Military', 'Overall Economy'}
bar_data = [{'category': group, 'value': sum(data[(data['Country Name'] == 'China') & (data['Indicator Code'].isin(indicators))]['2022'].fillna(0))} for group, indicators in indicator_groups.items()]
# Create and configure BarChart for China's economic indicators
bar_chart = lc.BarChart(theme=lc.Themes.Light, title="Bar Chart of Economic Indicators for China")
bar_chart.set_data(bar_data).set_sorting("descending").set_label_fitting(True).set_value_label_display_mode('afterBar')
bar_chart.open()
Global Economic Trends Over Time ( Polar Chart)
This code creates a polar chart showing normalized global indicator groups from 1990 to 2022, with each group (e.g., Agriculture, Finance) represented by a color-coded line over time. Unlike previous examples focused on a single year, this chart continuously presents year-over-year trends, revealing how each sector evolves across decades.
# Filter world data and define indicator groups
indicator_groups = {'Agriculture', 'Finance', 'Natural', 'Trade', 'Investment', 'Consumption', 'Military', 'Overall Economy'}
# Prepare polar chart for normalized indicator groups over time
chart = lc.PolarChart(theme=lc.Themes.Light, title="Normalized Indicator Groups for China")
# List years and assign random colors to each group
years = sorted(country_data['Year'].unique())
angles = np.linspace(0, 360, len(years), endpoint=False)
for group_name, indicators in indicator_groups.items():
group_data = country_data[country_data['Indicator Code'].isin(indicators)].groupby('Year')['Value'].mean().reindex(years).fillna(0)
normalized_values = (group_data - group_data.min()) / (group_data.max() - group_data.min())
data_points = [{'angle': angle, 'amplitude': value} for angle, value in zip(angles, normalized_values)]
line_series = chart.add_point_line_series().set_name(group_name).set_data(data_points)
line_series.set_stroke(thickness=2, color=lc.Color(f'#{random.randint(0, 0xFFFFFF):06x}'))
# Customize radial axis labels and display the chart
chart.get_radial_axis().set_division(27).set_tick_labels([str(year) for year in years])
chart.open()
Comparative Analysis of China and World Economic Trends by Sector (Polar Charts)
This code creates separate polar charts for each economic group, comparing China and the World by plotting normalized averages over time. Each chart shows area series for both China and World, revealing differences in economic trends per group across decades.
This approach contrasts with the previous unified polar chart by highlighting sector-specific insights, allowing a focused view of China’s performance relative to global averages in each category. This setup lets us quickly assess if China’s economic performance in each sector aligns with or diverges from global trends.
# Define indicator groups and filter data for China and World
indicator_groups = {'Agriculture', 'Finance', 'Natural', 'Trade', 'Investment', 'Consumption', 'Military', 'Overall Economy'}
years = sorted(china_data['Year'].unique())
angles = np.linspace(0, 360, len(years), endpoint=False)
for group_name, indicators in indicator_groups.items():
# Normalize yearly averages for China and World
china_normalized = (china_data[china_data['Indicator Code'].isin(indicators)].groupby('Year')['Value'].mean().reindex(years).fillna(0).pipe(lambda x: (x - x.min()) / (x.max() - x.min())))
world_normalized = (world_data[world_data['Indicator Code'].isin(indicators)].groupby('Year')['Value'].mean().reindex(years).fillna(0).pipe(lambda x: (x - x.min()) / (x.max() - x.min())))
# Prepare data points for PolarChart
china_data_points = [{"angle": angle, "amplitude": value} for angle, value in zip(angles, china_normalized)]
world_data_points = [{"angle": angle, "amplitude": value} for angle, value in zip(angles, world_normalized)]
# Create and configure PolarChart for each group
chart = lc.PolarChart(title=f"{group_name}: Average of Indicators - China vs World", theme=lc.Themes.Light)
chart.add_area_series().set_name("China").set_data(china_data_points)
chart.add_area_series().set_name("World").set_data(world_data_points)
chart.add_legend(horizontal=False, title=group_name).set_position(x=27.5, y=50)
chart.open()
Conclusion
This visualization analysis of World Development Indicators using LightningChart provided an insightful view of global trends. LightningChart’s flexibility in handling real-time, large datasets allowed for dynamic visualizations that reveal patterns and relationships within WDI. Such analysis is invaluable for informing policy, corporate strategies, and academic research on global development issues.
Continue learning with LightningChart
How to Create a Strip Chart
Written by a human | Updated on April 9th, 2025What is a Strip chart application and what are the modern equivalents to it? Before computers exist or were taking their first steps, a Strip chart was a way to visualize an analog electrical signal. Voltage was...
Data Visualization Template for Electron JS | LightningChart®
Updated on April 4th, 2025 | Written by humanAre you already building cross-platform applications with Electron JS? In some of our previous articles, we’ve worked on TypeScript projects where we created pie charts and vibration chart applications. And as we...
Bar chart race JavaScript
Updated on April 14th, 2025 | Written by humanBar chart race JavaScript When I wrote this article, the COVID-19 pandemic was at its peak point. Today, things are much better thanks to vaccinations that continued their steady positive global effect. With this bar...
