Matplotlib Complete Cheat Sheet
1. Basic Plot Setup
Function/Command Description Example
import [Link] as plt Standard import statement. import [Link] as plt
[Link]() Create new figure. [Link](figsize=(10,6))
[Link]() Display the plot. [Link]()
[Link]() Create figure & axes for subplots. fig, axes = [Link](2,2)
[Link]() Save plot as image file. [Link]('my_plot.png', dpi=300)
[Link]() Close current figure. [Link]()
2. Basic Plot Types
Function Description & Use Case Example
[Link]() Line plot. Track training loss. [Link](x,y)
[Link]() Scatter plot. Visualize clusters. [Link](X[:,0],X[:,1],c=y)
[Link]() Bar plot. Feature importance. [Link](categories,values)
[Link]() Histogram. Check distribution. [Link](data,bins=30)
[Link]() Box plot. Compare features/outliers. [Link]([data1,data2])
[Link]() Display 2D array/image. [Link](image_array)
[Link]() 2D colored grid. Decision boundaries. [Link](X,Y,Z)
3. Plot Customization & Styling
Function/Parameter Description Example
[Link]() Set plot title. [Link]('Model Accuracy')
[Link]() Set X-axis label. [Link]('Epochs')
[Link]() Set Y-axis label. [Link]('Accuracy')
[Link](), [Link]() Set axis limits. [Link](0,100)
[Link]() Show legend. [Link](['Train','Validation'])
[Link]() Add grid lines. [Link](True,alpha=0.3)
color Set line/point color. [Link](x,y,color='red')
linestyle Set line style. [Link](x,y,linestyle='--')
marker Set data markers. [Link](x,y,marker='o')
alpha Set transparency. [Link](x,y,alpha=0.5)
4. Specialized Plots for AIML
Technique Description & Use Case Example
Subplots Multiple plots together for before-after comparison. fig, axes = [Link]()
Confusion Matrix Analyze classifier performance. [Link]() + [Link]()
ROC Curve Binary classifier performance. [Link](FPR, TPR)
Learning Curves Train/validation loss over time to check overfitting. Multiple [Link]() calls
Decision Boundary Visualize class separation. [Link]() / [Link]()