Quiz 2

Matplotlib Deep Dive

108 words
1 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Matplotlib Deep Dive ## Matplotlib Best Practices - Use `plt.subplots()` (the OO API) instead of `plt.plot()` (pyplot) - Always include axis labels and titles - Use `fig.tight_layout()` to prevent overlapping - Set appropriate figure sizes - Export to SVG/PDF for vector graphics in publications [Join Discord](http...

Matplotlib Deep Dive

python
import matplotlib.pyplot as plt
import numpy as np
# Create figure and axes
fig, axes = plt.subplots(2, 2, figsize=(10, 8))
# Custom styling
plt.style.use('seaborn-v0_8-whitegrid')
# Annotations
x = np.linspace(0, 10, 100)
axes[0, 0].plot(x, np.sin(x), label='sin(x)')
axes[0, 0].annotate('Peak', xy=(np.pi/2, 1),
                     xytext=(np.pi/2, 1.2),
                     arrowprops=dict(arrowstyle='->'))
axes[0, 0].legend()
axes[0, 0].set_title('Sine Wave')
axes[0, 0].set_xlabel('x')
axes[0, 0].set_ylabel('sin(x)')
# Tight layout
plt.tight_layout()
plt.show()

Matplotlib Best Practices

  • Use plt.subplots() (the OO API) instead of plt.plot() (pyplot)
  • Always include axis labels and titles
  • Use fig.tight_layout() to prevent overlapping
  • Set appropriate figure sizes
  • Export to SVG/PDF for vector graphics in publications Join Discord PreviousAccessible DesignNextTool Comparison
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.