1. Matplotlib & Seaborn Architecture for Scientific Plotting
Matplotlib is the foundational 2D plotting library in Python. It uses a hierarchy of objects: the `Figure` (the overall canvas window) containing one or more `Axes` (individual coordinate systems with x-axis, y-axis, titles, and plot elements). Seaborn builds on top of Matplotlib to provide high-level statistical themes and beautiful color palettes tailored for multi-variable bio-data.
Setting up a publication-quality figure canvas with axes labels, grid lines, and custom legends.
import matplotlib.pyplot as plt
# Create Figure and Axes
fig, ax = plt.subplots(figsize=(8, 5), dpi=150)
time = [0, 1, 2, 4, 6, 8, 12]
conc = [0.0, 8.4, 12.6, 9.1, 5.2, 2.8, 0.7]
ax.plot(time, conc, marker='o', color='#10b981', linewidth=2, label='500mg Tablet')
ax.set_title('In Vivo Pharmacokinetic Absorption Profile', fontsize=14, fontweight='bold')
ax.set_xlabel('Time Post-Administration (hours)', fontsize=11)
ax.set_ylabel('Plasma Drug Concentration (ug/mL)', fontsize=11)
ax.grid(True, linestyle='--', alpha=0.6)
ax.legend(frameon=True)
plt.tight_layout()- `plt.subplots(nrows, ncols)` creates figure window and subplot axes arrays.
- `ax.plot()` creates continuous line charts; `ax.scatter()` plots discrete point data.
- `plt.savefig('pk_profile.png', dpi=300)` exports high-resolution figures for journal publications.
Matplotlib और Seaborn से वैज्ञानिक ग्राफ बनाए जाते हैं। Figure पूरा कैनवास होता है और Axes वह ग्राफ है जिस पर डेटा बिंदु और रेखाएं खींची जाती हैं।