{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import hvplot.pandas # noqa" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Kernel density estimate (`kde`) provides a mechanism for showing the distribution and spread of the data. In `hvplot` the method is exposed both as `kde` and `density`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from bokeh.sampledata import sea_surface_temperature as sst\n", "\n", "df = sst.sea_surface_temperature\n", "df.tail()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df.hvplot.kde()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are many options exposed and explorable using tab completion. In this case we'll create a colormap that spans the rainbow and divide the temperature by month." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import colorcet as cc" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "categorical_cmap = [cc.rainbow[int(i)] for i in np.linspace(0, 255, 12)]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df.hvplot.kde(by='time.month', cmap=categorical_cmap, legend='top', height=400)" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 2 }