All plt.
Functions in Matplotlib
matplotlib.pyplot (commonly imported as plt) offers a comprehensive set of plotting and utility
functions for interactive data visualization in Python. Below is an organized overview of the most
commonly used plt. functions grouped by category. This covers core plotting, figure management,
labels, and customization methods.
CORE PLOTTING FUNCTIONS
FUNCTION DESCRIPTION
plot() Line plot
scatter() Scatter plot (x, y points)
bar() Vertical bar chart
barh() Horizontal bar chart
hist() Histogram
boxplot() Box and whisker plot
pie() Pie chart
stem() Stem plot
fill() Filled polygons
fill_between() Fill area between curves
errorbar() Plot data with error bars
stackplot() Stacked area plots
step() Step plot
imshow() Display image data
contour() Contour plot
contourf() Filled contour plot
pcolormesh() Pseudocolor plot of 2D array
quiver() Field of arrows
barbs() Barbed arrows for vector fields
hexbin() Hexagonal binning plot
FIGURE AND AXES MANAGEMENT
Function Description
figure() Create new figure
subplots() Create figure and subplots (axes)
subplot() Add subplot to current figure
subplots_adjust()Adjust subplot parameters
clf() Clear current figure
cla() Clear current axes
close() Close a window
axes() Add or get axes from current figure
gcf() Get current figure
gca() Get current axes
CUSTOMIZATION & DECORATIONS
Function Description
title() Set plot title
xlabel() Set x-axis label
ylabel() Set y-axis label
legend() Display legend
xlim() Set x-axis limits
ylim() Set y-axis limits
xticks() Set x-axis tick locations/labels
yticks() Set y-axis tick locations/labels
grid() Show/Hide grid lines
text() Add text annotation
annotate() Annotate points with text/arrows
colorbar() Add colorbar to certain plots
DRAWING SHAPES AND LINES
Function Description
axhline() Add horizontal line across axes
axvline() Add vertical line across axes
axhspan() Add horizontal span (rectangle)
axvspan() Add vertical span (rectangle)
arrow() Add arrow to axes
DISPLAY, SAVE, OUTPUT
Function Description
show() Display the current figure
savefig() Save the current figure to a file
ADDITIONAL FUNCTIONALITIES
Function Description
subplot2grid() More flexible subplot layout
tight_layout() Automatically adjust subplot parameters
suptitle() Set centered title for figure with subplots