On the second step of this course the program asks:
Map out safety scores.
- Compute the average safety score for each district.
- Make a map that shows safety scores by district.
Screen Link: https://app.dataquest.io/m/217/guided-project%3A-analyzing-nyc-high-school-data/2/exploring-safety-and-sat-scores
Calculating the average is straightforward:
school_dist = combined.groupby("school_dist").agg(numpy.mean)
And we also get the lat and lon to display it.
But how do I draw a map where these averages are shown instead of the dot as normally the scatterplot would do?
Already found the answer:
from mpl_toolkits.basemap import Basemap
longitudes = districts_safety["lon"].tolist()
latitudes = districts_safety["lat"].tolist()
m = Basemap(
plt.title("District Safety Perception")
Thanks for this, I also found this helpful.
This is perhaps a new question but related so I will post here, it is to do with the size of the plot.
I have had a terrible time trying to just increase the size of the plot.
I have been looking at documentation : https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.figure.html
And trying all sorts of settings…
Any help out there on how to adjust the size of the map?
I can’t thank you enough for this! Have been stuck for some time now.