BaşlayınÜcretsiz Başlayın

Plotting shapefile polygons

The next step is to show the map of polygons. We have imported matplotlib.pyplot as plt and geopandas as gpd, and a GeoDataFrame of the service districts called service_district has been pre-loaded for you.

Bu egzersiz

Visualizing Geospatial Data in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • First plot the service districts without additional arguments by calling .plot() on the GeoDataFrame.
  • Take a look at it with plt.show(). This has been done for you.
  • Now use the .plot() method again, but this time add column='name' to color the shapes according to their names and legend=True to see those names. Remember to show the plot.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Import packages
import geopandas as gpd
import matplotlib.pyplot as plt

# Plot the Service Districts without any additional arguments
service_district.____()
plt.show()

# Plot the Service Districts, color them according to name, and show a legend
service_district.plot(____ = 'name', ____ = True)
plt.____()
Kodu Düzenle ve Çalıştır