{ "cells": [ { "cell_type": "markdown", "id": "3b507dd1-31f6-4732-bbc7-c82f2135fe1f", "metadata": {}, "source": [ "# Bar" ] }, { "cell_type": "code", "execution_count": null, "id": "5d0ed0f8-ce26-4c54-9161-d34ca73ae716", "metadata": {}, "outputs": [], "source": [ "import hvplot.xarray # noqa\n", "import xarray as xr" ] }, { "cell_type": "markdown", "id": "e3f7e297-9576-4c36-9a9f-a4200ccf2d36", "metadata": {}, "source": [ "## Introduction\n", "\n", "A `bar` plot represents **categorical data** with rectangular bars with heights proportional to the **numerical values** that they represent.\n", "The x-axis represents the categories and the y axis represents the numerical value scale.\n", "The bars are of equal width which allows for instant comparison of data." ] }, { "cell_type": "markdown", "id": "af429bbb-9a65-4b5d-b447-ce50b35dfedc", "metadata": {}, "source": [ "## Data\n", "\n", "Let's load some data." ] }, { "cell_type": "code", "execution_count": null, "id": "8db8fff7-b85f-49ea-b281-4a4d86e0f3ee", "metadata": {}, "outputs": [], "source": [ "ds = xr.tutorial.open_dataset('air_temperature').load()\n", "air = ds.air\n", "air1d = air.sel(lon=285.,lat=40.).groupby('time.month').mean()\n", "air1d" ] }, { "cell_type": "markdown", "id": "629c5172-9cba-4f5f-bf3b-67e0a390385b", "metadata": {}, "source": [ "## Basic Bar Plots" ] }, { "cell_type": "code", "execution_count": null, "id": "dfd1afa2-e310-4630-bd30-96e390078caf", "metadata": {}, "outputs": [], "source": [ "air1d.hvplot.bar(y='air', height=500, title=\"Air Temperature by Month\")" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 5 }