Home > Python > Plotting in Python

Ch. 5.1 Basic Plot and formatting

Chapters Index
Program 1

Basic Plot and formatting

Python 3.11 Ready

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

Mathematical Problem Formulation

Basic Line Plot
Program 2

Basic Plot and formatting

Python 3.11 Ready

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

Mathematical Problem Formulation

Basic Scatter Plot
Program 3

Basic Plot and formatting

Python 3.11 Ready

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

Mathematical Problem Formulation

Multiple Lines on same plot
Program 4

Basic Plot and formatting

Python 3.11 Ready

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

Mathematical Problem Formulation

Dual Axis Plot
Program 5

Basic Plot and formatting

Python 3.11 Ready

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

Mathematical Problem Formulation

Error Bar
Program 6

Basic Plot and formatting

Python 3.11 Ready

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

Mathematical Problem Formulation

Line Plot of Sine Function
Program 7

Basic Plot and formatting

Python 3.11 Ready

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

Mathematical Problem Formulation

User defined Function Plot
Program 8

Basic Plot and formatting

Python 3.11 Ready

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

Mathematical Problem Formulation

User Defined Function Plot
Theoretical Principles & Computational Physics Guide

Basic Plot and formatting: 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 Basic Plot and formatting 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).