{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Group barchart with units\n\nThis is the same example as\n:doc:`the barchart</gallery/lines_bars_and_markers/barchart>` in\ncentimeters.\n\n.. only:: builder_html\n\n   This example requires :download:`basic_units.py <basic_units.py>`\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from basic_units import cm, inch\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nN = 5\ntea_means = [15*cm, 10*cm, 8*cm, 12*cm, 5*cm]\ntea_std = [2*cm, 1*cm, 1*cm, 4*cm, 2*cm]\n\nfig, ax = plt.subplots()\nax.yaxis.set_units(inch)\n\nind = np.arange(N)    # the x locations for the groups\nwidth = 0.35         # the width of the bars\nax.bar(ind, tea_means, width, bottom=0*cm, yerr=tea_std, label='Tea')\n\ncoffee_means = (14*cm, 19*cm, 7*cm, 5*cm, 10*cm)\ncoffee_std = (3*cm, 5*cm, 2*cm, 1*cm, 2*cm)\nax.bar(ind + width, coffee_means, width, bottom=0*cm, yerr=coffee_std,\n       label='Coffee')\n\nax.set_title('Cup height by group and beverage choice')\nax.set_xticks(ind + width / 2, labels=['G1', 'G2', 'G3', 'G4', 'G5'])\n\nax.legend()\nax.autoscale_view()\n\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.14.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}