<jupyter_start><jupyter_text>Filled polygon`~.Axes.fill()` draws a filled polygon based based on lists of pointcoordinates *x*, *y*.This example uses the `Koch snowflake`_ as an example polygon.<jupyter_code>import numpy as np
import matplotlib.pyplot as plt


def koch_snowflake(order, scale=10):
    """
    Return two lists x, y of point coordinates of the Koch snowflake.

    Arguments
    ---------
    order : int
        The recursion depth.
    scale : float
        The extent of the snowflake (edge length of the base triangle).
    """
    def _koch_snowflake_complex(order):
        if order == 0:
            # initial triangle
            angles = np.array([0, 120, 240]) + 90
            return scale / np.sqrt(3) * np.exp(np.deg2rad(angles) * 1j)
        else:
            ZR = 0.5 - 0.5j * np.sqrt(3) / 3

            p1 = _koch_snowflake_complex(order - 1)  # start points
            p2 = np.roll(p1, shift=-1)  # end points
            dp = p2 - p1  # connection vectors

            new_points = np.empty(len(p1) * 4, dtype=np.complex128)
            new_points[::4] = p1
            new_points[1::4] = p1 + dp / 3
            new_points[2::4] = p1 + dp * ZR
            new_points[3::4] = p1 + dp / 3 * 2
            return new_points

    points = _koch_snowflake_complex(order)
    x, y = points.real, points.imag
    return x, y<jupyter_output><empty_output><jupyter_text>Basic usage:<jupyter_code>x, y = koch_snowflake(order=5)

plt.figure(figsize=(8, 8))
plt.axis('equal')
plt.fill(x, y)
plt.show()<jupyter_output><empty_output><jupyter_text>Use keyword arguments *facecolor* and *edgecolor* to modify the the colorsof the polygon. Since the *linewidth* of the edge is 0 in the defaultMatplotlib style, we have to set it as well for the edge to become visible.<jupyter_code>x, y = koch_snowflake(order=2)

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(9, 3),
                                    subplot_kw={'aspect': 'equal'})
ax1.fill(x, y)
ax2.fill(x, y, facecolor='lightsalmon', edgecolor='orangered', linewidth=3)
ax3.fill(x, y, facecolor='none', edgecolor='purple', linewidth=3)

plt.show()<jupyter_output><empty_output><jupyter_text>------------References""""""""""The use of the following functions, methods, classes and modules is shownin this example:<jupyter_code>import matplotlib
matplotlib.axes.Axes.fill
matplotlib.pyplot.fill
matplotlib.axes.Axes.axis
matplotlib.pyplot.axis<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1272430668841762, 'fraction_numerical': 0.026101141924959218, 'mean_word_length': 3.00163132137031, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '223044', 'license': 'MIT', 'n_tokens_mistral': 903, 'n_tokens_neox': 851, 'n_words': 221, 'path': 'matplotlib/gallery_jupyter/lines_bars_and_markers/fill.ipynb', 'repo_name': 'kingreatwill/penter', 'size': '2452'}