Home > Python > Plotting in Python

Ch. 5.8 Stream plot to Visualize Flow Data

Chapters Index
Program 1

Stream plot to Visualize Flow Data

Python 3.11 Ready

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

Mathematical Problem Formulation

2D Stream Plot
Program 2

Stream plot to Visualize Flow Data

Python 3.11 Ready

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

Mathematical Problem Formulation

Stream Plot with Varying Line Width
Program 4

Stream plot to Visualize Flow Data

Python 3.11 Ready

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

Mathematical Problem Formulation

Stream Plot with Custom Starting Points
Theoretical Principles & Computational Physics Guide

Stream plot to Visualize Flow Data: 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 Stream plot to Visualize Flow Data 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).