{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n===========================\nControl the plot's colorbar\n===========================\n\nUse ``cbar_kwargs`` keyword to specify the number of ticks.\nThe ``spacing`` kwarg can be used to draw proportional ticks.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nimport xarray as xr\n\n# Load the data\nair_temp = xr.tutorial.load_dataset('air_temperature')\nair2d = air_temp.air.isel(time=500)\n\n# Prepare the figure\nf, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(14, 4))\n\n# Irregular levels to illustrate the use of a proportional colorbar\nlevels = [245, 250, 255, 260, 265, 270, 275, 280, 285, 290, 310, 340]\n\n# Plot data\nair2d.plot(ax=ax1, levels=levels)\nair2d.plot(ax=ax2, levels=levels, cbar_kwargs={'ticks': levels})\nair2d.plot(ax=ax3, levels=levels, cbar_kwargs={'ticks': levels,\n                                               'spacing': 'proportional'})\n\n# Show plots\nplt.tight_layout()\nplt.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.6.5"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}