{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Circles, Wedges and Polygons\n\nThis example demonstrates how to use `.collections.PatchCollection`.\n\nSee also :doc:`/gallery/shapes_and_collections/artist_reference`, which instead\nadds each artist separately to its own Axes.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom matplotlib.collections import PatchCollection\nfrom matplotlib.patches import Circle, Polygon, Wedge\n\n# Fixing random state for reproducibility\nnp.random.seed(19680801)\n\n\nfig, ax = plt.subplots()\n\nresolution = 50  # the number of vertices\nN = 3\nx = np.random.rand(N)\ny = np.random.rand(N)\nradii = 0.1*np.random.rand(N)\npatches = []\nfor x1, y1, r in zip(x, y, radii):\n    circle = Circle((x1, y1), r)\n    patches.append(circle)\n\nx = np.random.rand(N)\ny = np.random.rand(N)\nradii = 0.1*np.random.rand(N)\ntheta1 = 360.0*np.random.rand(N)\ntheta2 = 360.0*np.random.rand(N)\nfor x1, y1, r, t1, t2 in zip(x, y, radii, theta1, theta2):\n    wedge = Wedge((x1, y1), r, t1, t2)\n    patches.append(wedge)\n\n# Some limiting conditions on Wedge\npatches += [\n    Wedge((.3, .7), .1, 0, 360),             # Full circle\n    Wedge((.7, .8), .2, 0, 360, width=0.05),  # Full ring\n    Wedge((.8, .3), .2, 0, 45),              # Full sector\n    Wedge((.8, .3), .2, 45, 90, width=0.10),  # Ring sector\n]\n\nfor i in range(N):\n    polygon = Polygon(np.random.rand(N, 2), closed=True)\n    patches.append(polygon)\n\ncolors = 100 * np.random.rand(len(patches))\np = PatchCollection(patches, alpha=0.4)\np.set_array(colors)\nax.add_collection(p)\nfig.colorbar(p, ax=ax)\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. admonition:: References\n\n   The use of the following functions, methods, classes and modules is shown\n   in this example:\n\n   - `matplotlib.patches`\n   - `matplotlib.patches.Circle`\n   - `matplotlib.patches.Wedge`\n   - `matplotlib.patches.Polygon`\n   - `matplotlib.collections.PatchCollection`\n   - `matplotlib.collections.Collection.set_array`\n   - `matplotlib.axes.Axes.add_collection`\n   - `matplotlib.figure.Figure.colorbar`\n\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.14.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}