{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Polygons" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import hvplot.pandas # noqa" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using hvplot with geopandas is as simple as loading a geopandas dataframe and calling `hvplot` on it with `geo=True`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geodatasets\n", "import geopandas as gpd\n", "\n", "chicago = gpd.read_file(geodatasets.get_path(\"geoda.chicago_commpop\"))\n", "chicago.sample(3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "chicago.hvplot(geo=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Control the color of the elements using the `c` option." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "chicago.hvplot.polygons(geo=True, c='POP2010', hover_cols='all')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can even color by another series, such as population density:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "chicago.hvplot.polygons(\n", " geo=True,\n", " c=chicago.POP2010/chicago.to_crs('EPSG:32616').area,\n", " clabel='pop density',\n", ")" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }