{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Plot Over Line {#plot_over_line_example}\n\nPlot the values of a dataset over a line through that dataset\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": [
        "# Volumetric Mesh\n\nFirst a 3D mesh example to demonstrate\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh = examples.download_kitchen()\n\n# Make two points to construct the line between\na = [mesh.bounds[0], mesh.bounds[2], mesh.bounds[4]]\nb = [mesh.bounds[1], mesh.bounds[3], mesh.bounds[5]]\n\n# Preview how this line intersects this mesh\nline = pv.Line(a, b)\n\np = pv.Plotter()\np.add_mesh(mesh, style=\"wireframe\", color=\"w\")\np.add_mesh(line, color=\"b\")\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Run the filter and produce a line plot\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh.plot_over_line(a, b, resolution=100)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Flat Surface\n\nWe could also plot the values of a mesh that lies on a flat surface\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh = examples.download_st_helens()\n\n# Make two points to construct the line between\na = [mesh.center[0], mesh.bounds[2], mesh.bounds[5]]\nb = [mesh.center[0], mesh.bounds[3], mesh.bounds[5]]\n\n# Preview how this line intersects this mesh\nline = pv.Line(a, b)\n\np = pv.Plotter()\np.add_mesh(mesh)\np.add_mesh(line, color=\"white\", line_width=10)\np.add_point_labels([a, b], [\"A\", \"B\"], font_size=48, point_color=\"red\", text_color=\"red\")\np.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Run the filter and produce a line plot\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh.plot_over_line(\n    a,\n    b,\n    resolution=10000,\n    title=\"Elevation Profile\",\n    ylabel=\"Height above sea level\",\n    figsize=(10, 5),\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.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}