.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_nyc_collisions_map.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_nyc_collisions_map.py: Pointplot of NYC fatal and injurious traffic collisions ======================================================= The example plots fatal (>=1 fatality) and injurious (>=1 injury requiring hospitalization) vehicle collisions in New York City. Injuries are far more common than fatalities. .. GENERATED FROM PYTHON SOURCE LINES 8-52 .. image:: /gallery/images/sphx_glr_plot_nyc_collisions_map_001.png :alt: Fatal Crashes in New York City, 2016, Injurious Crashes in New York City, 2016 :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Text(0.5, 1.0, 'Injurious Crashes in New York City, 2016') | .. code-block:: default import geopandas as gpd import geoplot as gplt import geoplot.crs as gcrs import matplotlib.pyplot as plt # load the data nyc_boroughs = gpd.read_file(gplt.datasets.get_path('nyc_boroughs')) nyc_fatal_collisions = gpd.read_file(gplt.datasets.get_path('nyc_fatal_collisions')) nyc_injurious_collisions = gpd.read_file(gplt.datasets.get_path('nyc_injurious_collisions')) fig = plt.figure(figsize=(10, 5)) proj = gcrs.AlbersEqualArea(central_latitude=40.7128, central_longitude=-74.0059) ax1 = plt.subplot(121, projection=proj) ax2 = plt.subplot(122, projection=proj) ax1 = gplt.pointplot( nyc_fatal_collisions, projection=proj, hue='BOROUGH', cmap='Set1', edgecolor='white', linewidth=0.5, scale='NUMBER OF PERSONS KILLED', limits=(8, 24), legend=True, legend_var='scale', legend_kwargs={'loc': 'upper left', 'markeredgecolor': 'black'}, legend_values=[2, 1], legend_labels=['2 Fatalities', '1 Fatality'], ax=ax1 ) gplt.polyplot(nyc_boroughs, ax=ax1) ax1.set_title("Fatal Crashes in New York City, 2016") gplt.pointplot( nyc_injurious_collisions, projection=proj, hue='BOROUGH', cmap='Set1', edgecolor='white', linewidth=0.5, scale='NUMBER OF PERSONS INJURED', limits=(4, 20), legend=True, legend_var='scale', legend_kwargs={'loc': 'upper left', 'markeredgecolor': 'black'}, legend_values=[20, 15, 10, 5, 1], legend_labels=['20 Injuries', '15 Injuries', '10 Injuries', '5 Injuries', '1 Injury'], ax=ax2 ) gplt.polyplot(nyc_boroughs, ax=ax2, projection=proj) ax2.set_title("Injurious Crashes in New York City, 2016") .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.873 seconds) .. _sphx_glr_download_gallery_plot_nyc_collisions_map.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_nyc_collisions_map.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_nyc_collisions_map.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_