Home > Python > Plotting in Python

Ch. 5.5 Pie Chart

Chapters Index
Program 1

Pie Chart

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Pie Chart with Exploded Slices
Program 2

Pie Chart

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Pie Chart with Percentage Labels Only
Theoretical Principles & Computational Physics Guide

Pie Chart: Scientific Visualization & Field Mapping

Dr. Alorika Chatterjee & Dr. Anirban Shaw Science & Physics Learners Python 3 / NumPy / SciPy

1. Core Principles & Theoretical Framework

Graphical Representation: Translates raw numerical simulation arrays into intuitive 2D/3D graphical curves, vector fields, and heatmaps.
Physical Field Representation: Renders electrostatic equipotentials, fluid streamlines, and phase-space trajectories with exact physical coordinates.
Perceptual Color Mapping: Employs scientifically calibrated colormaps (Viridis, Plasma) to represent continuous scalar potentials without visual artifacting.

2. Mathematical Formulation & Algorithmic Pipeline

Vector field mapping and scalar field potential gradients:

$$ \mathbf{E}(\mathbf{r}) = -\nabla V(\mathbf{r}) = -\left(\frac{\partial V}{\partial x}\hat{i} + \frac{\partial V}{\partial y}\hat{j}\right), \quad \Phi(x, y) = \text{Scalar Height} $$
1. Discretized Meshgrid $(X, Y)$ → 2. Field Evaluation $Z = f(X, Y)$ → 3. Render Plot with Units & Labels

3. Numerical Mechanics & Implementation Logic

  • Grid Generation: Create 2D coordinate meshgrids using np.meshgrid(x, y).
  • Field Computation: Vectorize mathematical equations across the entire coordinate mesh.
  • Styling & Labeling: Add scientific axis labels with physical units, informative legends, and high-contrast colorbars.

4. Relevant Computational Practice Exercises

Exercise 1
Generate the plot for Pie Chart and adjust parameter inputs to observe how the visual field distribution shifts.
Exercise 2
Add proper LaTeX formatting to graph axes, title, and colorbar legends for publication-quality figures.
Exercise 3
Export the generated figure to vector SVG or high-resolution PNG format.
Standard Literature & References:
  • John D. Hunter, "Matplotlib: A 2D Graphics Environment", Computing in Science & Engineering (2007).
  • Mark Newman, "Computational Physics", University of Michigan (2013).