Untitled
Anonymous
plain_text
02/27/2026 8:11 PM
2.6 KB
12
Indexable
import matplotlib.pyplot as plt
# المعطيات من الجدول
years = ['1950', '1990', '2025']
population = [76.8, 223.4, 463.3] # مليون نسمة
water_share = [4183.2, 1303.1, 553.8] # متر مكعب/سنة
fig, ax1 = plt.subplots(figsize=(10, 6))
# رسم أعمدة السكان (المحور الأيمن)
color_pop = 'skyblue'
ax1.set_xlabel('السنوات (Years)')
ax1.set_ylabel('مجموع السكان (مليون نسمة)', color='blue', fontsize=12)
bars = ax1.bar(years, population, color=color_pop, alpha=0.7, label='مجموع السكان (م.ن)')
ax1.tick_params(axis='y', labelcolor='blue')
ax1.set_ylim(0, 550)
# إضافة القيم فوق الأعمدة
for bar in bars:
yval = bar.get_height()
ax1.text(bar.get_x() + bar.get_width()/2, yval + 5, yval, ha='center', va='bottom', color='blue', fontweight='bold')
# إنشاء محور ثانٍ لحصة الماء (المحور الأيسر)
ax2 = ax1.twinx()
color_water = 'red'
ax2.set_ylabel('حصة الفرد من الماء (متر مكعب/السنة)', color=color_water, fontsize=12)
line = ax2.plot(years, water_share, color=color_water, marker='o', linewidth=2, label='حصة الفرد من الماء')
ax2.tick_params(axis='y', labelcolor='red')
ax2.set_ylim(0, 5000)
# إضافة القيم فوق المنحنى
for i, txt in enumerate(water_share):
ax2.annotate(txt, (years[i], water_share[i]), textcoords="offset points", xytext=(0,10), ha='center', color='red', fontweight='bold')
# العنوان والعناصر الإضافية
plt.title('مبيان تطور عدد السكان وحصة الفرد من الماء بالعالم العربي (1950 - 2025)', fontsize=14, pad=20)
plt.grid(axis='y', linestyle='--', alpha=0.3)
# إضافة المصدر أسفل المبيان
plt.figtext(0.5, -0.05, 'المصدر: المجلس العربي للمياه، 2013', ha='center', fontsize=10, style='italic')
plt.tight_layout()
plt.show()Editor is loading...
Leave a Comment