How can I display both the smallest
and largest
on a single plot.
My current code is this:
import matplotlib.pyplot as plt
smallest = lsoas.sort_values('imd_score').head(10)
largest = lsoas.sort_values('imd_score').head(10)
f, ax = plt.subplots(1, figsize=(6, 6))
lsoas.plot(facecolor='black', linewidth=0.025, ax=ax)
smallest.plot(alpha=1, facecolor='red', linewidth=0, ax=ax)
largest.plot(alpha=1, facecolor='blue', linewidth=0, ax=ax)
ax.set_axis_off()
f.suptitle('Areas with smallest population')
plt.axis('equal')
plt.show()
but this only shows the largest
.
While your code isn't exactly reproducible ( lsoas
is not defined), it appears you're setting both smallest
and largest
to head(10)
, so they're defined as the same thing. Use tail(10)
for the smallest value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.