.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_ny_state_demographics.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_ny_state_demographics.py: Choropleth of New York State population demographics ==================================================== This example plots the percentage of residents in New York State by county who self-identified as "white" in the 2000 census. New York City is far more ethnically diversity than the rest of the state. .. GENERATED FROM PYTHON SOURCE LINES 9-30 .. image:: /gallery/images/sphx_glr_plot_ny_state_demographics_001.png :alt: Percentage White Residents, 2000 :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Text(0.5, 1.0, 'Percentage White Residents, 2000') | .. code-block:: default import geopandas as gpd import geoplot as gplt import geoplot.crs as gcrs import matplotlib.pyplot as plt ny_census_tracts = gpd.read_file(gplt.datasets.get_path('ny_census')) ny_census_tracts = ny_census_tracts.assign( percent_white=ny_census_tracts['WHITE'] / ny_census_tracts['POP2000'] ) gplt.choropleth( ny_census_tracts, hue='percent_white', cmap='Purples', linewidth=0.5, edgecolor='white', legend=True, projection=gcrs.AlbersEqualArea() ) plt.title("Percentage White Residents, 2000") .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.666 seconds) .. _sphx_glr_download_gallery_plot_ny_state_demographics.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_ny_state_demographics.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_ny_state_demographics.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_