{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Identify whether artists intersect\n\nThe lines intersecting the rectangle are colored in red, while the others\nare left as blue lines. This example showcases the `.intersects_bbox` function.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom matplotlib.path import Path\nfrom matplotlib.transforms import Bbox\n\n# Fixing random state for reproducibility\nnp.random.seed(19680801)\n\n\nleft, bottom, width, height = (-1, -1, 2, 2)\nrect = plt.Rectangle((left, bottom), width, height,\n                     facecolor=\"black\", alpha=0.1)\n\nfig, ax = plt.subplots()\nax.add_patch(rect)\n\nbbox = Bbox.from_bounds(left, bottom, width, height)\n\nfor i in range(12):\n    vertices = (np.random.random((2, 2)) - 0.5) * 6.0\n    path = Path(vertices)\n    if path.intersects_bbox(bbox):\n        color = 'r'\n    else:\n        color = 'b'\n    ax.plot(vertices[:, 0], vertices[:, 1], color=color)\n\nplt.show()"
      ]
    }
  ],
  "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
}