{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import hvplot.pandas # noqa" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`area` can be used to color the area under a line or to color the space between two lines. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "from bokeh.sampledata.degrees import data\n", "\n", "data.tail()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we'll look at a single curve, where we are enforcing the y axis must be between 0 and 100 and we set the background color." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data.hvplot.area(x='Year', y='Computer Science', label='% of Computer Science Degrees Earned by Women',\n", " ylim=(0, 100), width=500, height=400).opts(bgcolor='goldenrod')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from bokeh.sampledata.stocks import MSFT\n", "\n", "df = pd.DataFrame(MSFT)\n", "df['date'] = pd.to_datetime(df.date)\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To color the area between two curves, include both a `y` and a `y2`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df[df.date.dt.year == 2000].hvplot.area(x='date', y='low', y2='high')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When multiple y values are passed, they are stacked by default." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df.hvplot.area(x='date', y=['open', 'close'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Area plots can also be unstacked:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df.hvplot.area(x='date', y=['open', 'close'], stacked=False,\n", " groupby='date.year', legend='bottom_right', width=500)" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }