Understanding Figure and Axes
The Figure and Axes are the two most important objects in Matplotlib. Understanding them is key to creating any visualization.
The Hierarchy
Matplotlib organizes plots in a hierarchy:
Figure (the overall window/canvas)
└── Axes (an individual plot/chart)
├── XAxis (the x-axis)
├── YAxis (the y-axis)
├── Title
├── Lines, Bars, etc. (the actual data)
└── Legend, Grid, etc.
جارٍ تحميل ساحة تجربة Python...
Creating Figures and Axes
There are several ways to create figures and axes:
Method 1: plt.subplots() (Recommended)
جارٍ تحميل ساحة تجربة Python...
Method 2: plt.figure() + add_subplot()
جارٍ تحميل ساحة تجربة Python...
Figure Properties
The Figure object controls the overall appearance:
جارٍ تحميل ساحة تجربة Python...
Axes Properties
Each Axes object has many customizable properties:
جارٍ تحميل ساحة تجربة Python...
Working with Multiple Axes
Grid of Subplots
جارٍ تحميل ساحة تجربة Python...
Shared Axes
جارٍ تحميل ساحة تجربة Python...
Adjusting Spacing
جارٍ تحميل ساحة تجربة Python...
Practice: Create a Multi-Panel Figure
جارٍ تحميل تمرين Python...
Key Takeaways
- Figure is the overall container (like a canvas or window)
- Axes is an individual plot within the figure
- Use
plt.subplots(rows, cols)to create figures with multiple axes - Access axes in a grid using
axes[row, col]indexing - Customize figures with
figsize,facecolor,dpi - Customize axes with
set_title(),set_xlabel(),set_xlim(),set_xticks() - Use
sharex=Trueorsharey=Truefor linked axes - Use
plt.tight_layout()for automatic spacing
In the next lesson, we'll explore the basic plotting commands you'll use most often.
التالي · الدرس 7 من 38
Basic Plotting Commands
قراءة 1 دقيقة
أنهيت 6 من 38 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

