hvPlot.polygons#
- hvPlot.polygons(x=None, y=None, c=None, **kwds)[source]#
Polygon plot for geopandas dataframes.
Reference: https://hvplot.holoviz.org/ref/api/manual/hvplot.hvPlot.polygons.html
Plotting options: https://hvplot.holoviz.org/ref/plotting_options/index.html
- Parameters:
- cstring, optional
The dimension to color the polygons by
- logzbool
Enables logarithmic colormapping. Default is False.
- **kwdsoptional
Additional keywords arguments are documented in Plotting Options. Run
hvplot.help('polygons')for the full method documentation.
- Returns:
holoviews.element.Polygons/ Panel objectYou can print the object to study its composition and run:
import holoviews as hv hv.help(the_holoviews_object)
to learn more about its parameters and options.
Backend-specific styling options#
alpha, cmap, color, fill_alpha, fill_color, hover_alpha, hover_color, hover_fill_alpha, hover_fill_color, hover_line_alpha, hover_line_cap, hover_line_color, hover_line_dash, hover_line_dash_offset, hover_line_join, hover_line_width, line_alpha, line_cap, line_color, line_dash, line_dash_offset, line_join, line_width, muted, muted_alpha, muted_color, muted_fill_alpha, muted_fill_color, muted_line_alpha, muted_line_cap, muted_line_color, muted_line_dash, muted_line_dash_offset, muted_line_join, muted_line_width, nonselection_alpha, nonselection_color, nonselection_fill_alpha, nonselection_fill_color, nonselection_line_alpha, nonselection_line_cap, nonselection_line_color, nonselection_line_dash, nonselection_line_dash_offset, nonselection_line_join, nonselection_line_width, selection_alpha, selection_color, selection_fill_alpha, selection_fill_color, selection_line_alpha, selection_line_cap, selection_line_color, selection_line_dash, selection_line_dash_offset, selection_line_join, selection_line_width, visible
alpha, c, capstyle, cmap, color, ec, ecolor, edgecolor, facecolor, fc, fill, hatch, joinstyle, linestyle, linewidth, lw
Examples#
Basic polygons plot#
In this example we display a very simple polygons plot, from a GeoPandas GeoDataFrame built from Shapely Polygons.
import geopandas as gpd
import hvplot.pandas # noqa
from shapely.geometry import Polygon
poly1 = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])
poly2 = Polygon([(1, 1), (2, 1), (2, 2), (1, 2)])
poly3 = Polygon([(2, 2), (3, 2), (3, 3), (2, 3)])
gdf = gpd.GeoDataFrame({'geometry': [poly1, poly2, poly3]})
gdf.hvplot.polygons()
Choropleth/thematic map with c#
The c option (alias for color) can be used to generate choropleth and thematic maps. While not strictly required for this dataset in WGS84, we set geo to True to demonstrate that polygons support being displayed with GeoViews. We additionally set tiles to True to overlay the polygons on web map tiles.
This first example sets the logz keyword to True, as there are a few states with very low and high population densities, that would make a linear scale inappropriate (this is equivalent to setting the cnorm to 'log').
import hvplot.pandas # noqa
gdf = hvplot.sampledata.us_states("geopandas")
gdf.hvplot.polygons(
color="pop_density", logz=True, data_aspect=1, geo=True, tiles=True,
frame_width=500, title="Choropleth map", clabel="Population density",
)
import hvplot.pandas # noqa
gdf = hvplot.sampledata.us_states("geopandas")
gdf.hvplot.polygons(
color="bea_region", data_aspect=1, geo=True, tiles=True,
frame_width=500, title="Thematic map",
)