{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Text annotations in 3D\n\nDemonstrates the placement of text annotations on a 3D plot.\n\nFunctionality shown:\n\n- Using the `~.Axes3D.text` function with three types of *zdir* values: None,\n  an axis name (ex. 'x'), or a direction tuple (ex. (1, 1, 0)).\n- Using the `~.Axes3D.text` function with the color keyword.\n- Using the `.text2D` function to place text on a fixed position on the ax\n  object.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nax = plt.figure().add_subplot(projection='3d')\n\n# Demo 1: zdir\nzdirs = (None, 'x', 'y', 'z', (1, 1, 0), (1, 1, 1))\nxs = (1, 4, 4, 9, 4, 1)\nys = (2, 5, 8, 10, 1, 2)\nzs = (10, 3, 8, 9, 1, 8)\n\nfor zdir, x, y, z in zip(zdirs, xs, ys, zs):\n    label = '(%d, %d, %d), dir=%s' % (x, y, z, zdir)\n    ax.text(x, y, z, label, zdir)\n\n# Demo 2: color\nax.text(9, 0, 0, \"red\", color='red')\n\n# Demo 3: text2D\n# Placement 0, 0 would be the bottom left, 1, 1 would be the top right.\nax.text2D(0.05, 0.95, \"2D Text\", transform=ax.transAxes)\n\n# Tweaking display region and labels\nax.set_xlim(0, 10)\nax.set_ylim(0, 10)\nax.set_zlim(0, 10)\nax.set_xlabel('X axis')\nax.set_ylabel('Y axis')\nax.set_zlabel('Z axis')\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. tags::\n   plot-type: 3D,\n   component: annotation,\n   level: beginner\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
}