<jupyter_start><jupyter_text>Title  Polygons Element  Dependencies Bokeh  Backends Bokeh Matplotlib<jupyter_code>import numpy as np
import holoviews as hv
hv.extension('bokeh')<jupyter_output><empty_output><jupyter_text>A ``Polygons`` object is similar to a ``Contours`` object except that each supplied path is closed and filled. Just like ``Contours``, an optional ``level`` value may be supplied; the Polygons will then be colored according to the supplied ``cmap``. Non-finite values such as ``np.NaN`` or ``np.inf`` will default to the supplied ``facecolor``.Polygons with values can be used to build heatmaps with arbitrary shapes.<jupyter_code>%%opts Polygons (cmap='hot' line_color='black' line_width=2)
np.random.seed(35)
hv.Polygons([np.random.rand(4,2)], level=0.5) *\
hv.Polygons([np.random.rand(4,2)], level=1.0) *\
hv.Polygons([np.random.rand(4,2)], level=1.5) *\
hv.Polygons([np.random.rand(4,2)], level=2.0)<jupyter_output><empty_output><jupyter_text>``Polygons`` without a value are useful as annotation, but also allow us to draw arbitrary shapes.<jupyter_code>def rectangle(x=0, y=0, width=1, height=1):
    return np.array([(x,y), (x+width, y), (x+width, y+height), (x, y+height)])

(hv.Polygons([rectangle(width=2), rectangle(x=6, width=2)]).opts(style={'fill_color': '#a50d0d'})
* hv.Polygons([rectangle(x=2, height=2), rectangle(x=5, height=2)]).opts(style={'fill_color': '#ffcc00'})
* hv.Polygons([rectangle(x=3, height=2, width=2)]).opts(style={'fill_color': 'cyan'}))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17465528562048588, 'fraction_numerical': 0.02495075508864084, 'mean_word_length': 7.419889502762431, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '497717', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 582, 'n_tokens_neox': 570, 'n_words': 131, 'path': 'examples/reference/elements/bokeh/Polygons.ipynb', 'repo_name': 'stonebig/holoviews', 'size': '1523'}