This repository contains educational materials for learning data visualization in Python using plotnine, a powerful implementation of the Grammar of Graphics. These notebooks are designed to be run in Google Colab, making them easily accessible for students without requiring local installation of Python or any dependencies.
These materials cover fundamental concepts of data visualization using Python's plotnine library, which is based on R's ggplot2. The exercises are hands-on and interactive, allowing you to experiment with different visualization techniques and understand their applications in real-world scenarios.
Click on the link below to open the notebook directly in Google Colab:
Chapter 3.4 - Python and Plotnine
Introduction to data visualization with plotnine
Chapter 3.4.1 - Evolve a Chart
Learn how to iteratively improve and refine your visualizations
Chapter 3.4.2 - Python and Plotnine Workshop (Corruption)
Practical exercises exploring corruption and development data visualization
- Click on any "Open in Colab" badge above to open the notebook in Google Colab
- If prompted, sign in with your Google account
- Save a copy of the notebook to your Google Drive to keep your work
- Install required dependencies:
plotnine==0.14.5
- Execute the cells and follow the instructions within the notebook
- A Google account to access Google Colab
- Basic understanding of Python syntax
- Familiarity with pandas DataFrames
- No local installation required - everything runs in the cloud!
- Grammar of Graphics fundamentals
- Basic plotting with plotnine:
- Line plots
- Scatter plots
- Bar charts
- Box plots
- Histograms
- Advanced features:
- Aesthetics mapping
- Faceting
- Statistical transformations
- Coordinates
- Scales
- Themes
- Data visualization best practices
- Chart refinement and evolution
The notebooks contain:
- Theoretical explanations of the Grammar of Graphics
- Code examples with visual outputs
- Progressive complexity from basic to advanced features
- Real-world applications using various datasets
- Interactive exercises for learning
- Step-by-step guide to improve visualizations
Each section builds upon previous concepts and includes working examples that can be modified and experimented with.
- Grammar of Graphics implementation
- Declarative visualization creation
- Layered approach to plotting
- Statistical transformations
- Faceting for multi-panel plots
- Theme customization
- Scale modifications
- Coordinate system adjustments
- Remember to save your work periodically in Google Colab
- The runtime may disconnect after periods of inactivity
- Make sure to install all required dependencies at the start of your session
- If you're familiar with R's ggplot2, you'll find plotnine's syntax very similar
The notebooks are designed to provide a comprehensive introduction to plotnine's capabilities while maintaining an interactive and hands-on learning approach.