{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Multi-Line Temperature Profile Plot\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nimport iris\nimport iris.plot as iplt\nimport iris.quickplot as qplt\n\n\ndef main():\n    fname = iris.sample_data_path(\"air_temp.pp\")\n\n    # Load exactly one cube from the given file.\n    temperature = iris.load_cube(fname)\n\n    # We only want a small number of latitudes, so filter some out\n    # using \"extract\".\n    temperature = temperature.extract(\n        iris.Constraint(latitude=lambda cell: 68 <= cell < 78)\n    )\n\n    for cube in temperature.slices(\"longitude\"):\n\n        # Create a string label to identify this cube (i.e. latitude: value).\n        cube_label = \"latitude: %s\" % cube.coord(\"latitude\").points[0]\n\n        # Plot the cube, and associate it with a label.\n        qplt.plot(cube, label=cube_label)\n\n    # Add the legend with 2 columns.\n    plt.legend(ncol=2)\n\n    # Put a grid on the plot.\n    plt.grid(True)\n\n    # Tell matplotlib not to extend the plot axes range to nicely\n    # rounded numbers.\n    plt.axis(\"tight\")\n\n    # Finally, show it.\n    iplt.show()\n\n\nif __name__ == \"__main__\":\n    main()"
      ]
    }
  ],
  "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.10.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}