การพล็อตย่าน Urban Residents และงานศิลปะ
ตอนนี้คุณทราบแล้วว่างานศิลปะส่วนใหญ่อยู่ในย่าน Urban Residents ในแบบฝึกหัดนี้ จะสร้างพล็อตแสดงงานศิลปะในย่านนั้น โดยเริ่มจากการกรองเฉพาะ urban_art จาก neighborhood_art และกรอง urban_polygon จาก neighborhoods จากนั้นสร้างพล็อต polygon เป็น ax ก่อน แล้วจึงเพิ่มพล็อตของงานศิลปะลงไป
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การแสดงผลข้อมูลเชิงภูมิศาสตร์ด้วย Python
คำแนะนำการฝึกหัด
- สร้าง GeoDataFrame ชื่อ
urban_artโดยใช้ตัวเข้าถึง.loc[]เพื่อดึงเฉพาะงานศิลปะในย่าน"Urban Residents" - ใช้
.loc[]อีกครั้งเพื่อสร้าง GeoDataFrame ชื่อurban_polygonจากneighborhoodsโดยดึงเฉพาะ polygon ของ"Urban Residents" - พล็อต
urban_polygonเป็นaxและกำหนดcolorเป็นlightgreen - พล็อตงานศิลปะใน
urban_artโดยส่งอาร์กิวเมนต์ 3 ตัว ได้แก่ กำหนดax = axเพื่อเพิ่มพล็อตนี้ลงบนurban_polygonใช้typeเพื่อกำกับชื่อจุด และกำหนดlegend = True
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Create urban_art from neighborhood_art where the neighborhood name is Urban Residents
urban_art = neighborhood_art.loc[neighborhood_art.name == ____]
# Get just the Urban Residents neighborhood polygon and save it as urban_polygon
urban_polygon = neighborhoods.loc[____.____ == "Urban Residents"]
# Plot the urban_polygon as ax
ax = ____.____(color = 'lightgreen')
# Add a plot of the urban_art and show it
urban_art.plot( ax = ax, ____ = 'type', legend = True);
plt.show()