Basic Plotting Commands
Matplotlib provides a rich set of plotting functions. In this lesson, we'll cover the essential commands you'll use most frequently.
The plot() Function
The plot() function creates line plots and is the most versatile plotting command:
Format Strings
Matplotlib uses format strings for quick styling:
Using Keyword Arguments
For more control, use keyword arguments:
The scatter() Function
For scatter plots showing relationships between variables:
Color-Coded Scatter Plots
Map a third variable to color:
The bar() and barh() Functions
For categorical comparisons:
Customizing Bars
The hist() Function
For showing data distributions:
Comparing Distributions
Combining Plot Types
You can combine different plot types on the same axes:
Practice: Create Multiple Plot Types
Quick Reference
| Function | Use Case | Key Parameters |
|---|---|---|
plot() | Line plots | color, linewidth, linestyle, marker |
scatter() | Point plots | c, s, cmap, alpha |
bar()/barh() | Category comparisons | color, width, edgecolor |
hist() | Distributions | bins, color, alpha, edgecolor |
Key Takeaways
plot()creates line plots; use format strings for quick stylingscatter()creates point plots; usecfor color mappingbar()andbarh()create vertical and horizontal bar chartshist()shows data distribution; adjustbinsfor granularity- Combine plot types on the same axes for rich visualizations
- Use
alphafor transparency when overlapping elements
In the next module, we'll dive deeper into line and scatter plots for visualizing trends and relationships.
Quiz
Up next · Lesson 8 of 38
Creating Line Plots
2 min read
7 of 38 lessons done

Ask Byte about this lesson
A private chat about this lesson. Byte has read the whole lesson, answers in seconds, and shows the section each answer comes from. Ask follow-ups in any language.
Questions & Answers
Public questions about this lesson. The AI Tutor answers right away in your language, the FreeAcademy team checks answers, and every learner can read them.

