{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Plot Vector Component\n\nPlot a single component of a vector as a scalar array.\n\nWe can plot individual components of multi-component arrays with the\n`component` argument of the `add_mesh` method.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import pyvista as pv\nfrom pyvista import examples"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Download an example notched beam stress\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh = examples.download_notch_displacement()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The default behavior with no component specified is to use the vector\nmagnitude. We can access each component by specifying the component\nargument.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "dargs = dict(\n    scalars=\"Nodal Displacement\",\n    cmap=\"jet\",\n    show_scalar_bar=False,\n)\n\npl = pv.Plotter(shape=(2, 2))\npl.subplot(0, 0)\npl.add_mesh(mesh, **dargs)\npl.add_text(\"Normalized Displacement\", color='k')\npl.subplot(0, 1)\npl.add_mesh(mesh.copy(), component=0, **dargs)\npl.add_text(\"X Displacement\", color='k')\npl.subplot(1, 0)\npl.add_mesh(mesh.copy(), component=1, **dargs)\npl.add_text(\"Y Displacement\", color='k')\npl.subplot(1, 1)\npl.add_mesh(mesh.copy(), component=2, **dargs)\npl.add_text(\"Z Displacement\", color='k')\npl.link_views()\npl.camera_position = 'iso'\npl.background_color = 'white'\npl.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.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}