{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Primary 3D view planes\n\nThis example generates an \"unfolded\" 3D plot that shows each of the primary 3D\nview planes. The elevation, azimuth, and roll angles required for each view are\nlabeled. You could print out this image and fold it into a box where each plane\nforms a side of the box.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\n\ndef annotate_axes(ax, text, fontsize=18):\n    ax.text(x=0.5, y=0.5, z=0.5, s=text,\n            va=\"center\", ha=\"center\", fontsize=fontsize, color=\"black\")\n\n# (plane, (elev, azim, roll))\nviews = [('XY',   (90, -90, 0)),\n         ('XZ',    (0, -90, 0)),\n         ('YZ',    (0,   0, 0)),\n         ('-XY', (-90,  90, 0)),\n         ('-XZ',   (0,  90, 0)),\n         ('-YZ',   (0, 180, 0))]\n\nlayout = [['XY',  '.',   'L',   '.'],\n          ['XZ', 'YZ', '-XZ', '-YZ'],\n          ['.',   '.', '-XY',   '.']]\nfig, axd = plt.subplot_mosaic(layout, subplot_kw={'projection': '3d'},\n                              figsize=(12, 8.5))\nfor plane, angles in views:\n    axd[plane].set_xlabel('x')\n    axd[plane].set_ylabel('y')\n    axd[plane].set_zlabel('z')\n    axd[plane].set_proj_type('ortho')\n    axd[plane].view_init(elev=angles[0], azim=angles[1], roll=angles[2])\n    axd[plane].set_box_aspect(None, zoom=1.25)\n\n    label = f'{plane}\\n{angles}'\n    annotate_axes(axd[plane], label, fontsize=14)\n\nfor plane in ('XY', '-XY'):\n    axd[plane].set_zticklabels([])\n    axd[plane].set_zlabel('')\nfor plane in ('XZ', '-XZ'):\n    axd[plane].set_yticklabels([])\n    axd[plane].set_ylabel('')\nfor plane in ('YZ', '-YZ'):\n    axd[plane].set_xticklabels([])\n    axd[plane].set_xlabel('')\n\nlabel = 'mplot3d primary view planes\\n' + 'ax.view_init(elev, azim, roll)'\nannotate_axes(axd['L'], label, fontsize=18)\naxd['L'].set_axis_off()\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. tags::\n   plot-type: 3D,\n   component: axes, component: subplot,\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.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}