Plotting the Urban Residents neighborhood and art
Now you know that most art is in the Urban Residents neighborhood. In this exercise, you'll create a plot of art in that neighborhood. First you will subset just the urban_art
from neighborhood_art
and you'll subset the urban_polygon
from neighborhoods
. Then you will create a plot of the polygon as ax
before adding a plot of the art.
This exercise is part of the course
Visualizing Geospatial Data in Python
Exercise instructions
- Create a GeoDataFrame called
urban_art
using the.loc[]
accessor to get only the art in the"Urban Residents"
neighborhood. - Use
.loc[]
again to create a GeoDataFrame calledurban_polygon
fromneighborhoods
with only the"Urban Residents"
polygon. - Plot
urban_polygon
asax
and setcolor
tolightgreen
. - Plot the art in
urban_art
. Pass three arguments: Setax = ax
to add this plot to theurban_polygon
, usetype
to label the points, and setlegend = True
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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()