{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Image" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import hvplot.xarray # noqa" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "\n", "ds = xr.tutorial.open_dataset('air_temperature')\n", "ds" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When data values are available on an x, y grid, they can often be represented as an `image`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds.hvplot.image()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is equivalent to specifying:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds.hvplot.image(x='lon', y='lat', z='air', groupby='time', cmap='kbc_r')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A simpler case would be to take the temperature at just one day. Here we'll show how to use `clabel` to control the colorbar and also demonstrate how when the data are symmetric around 0, the \"coolwarm\" colormap is used by default." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "time = '2014-01-01'\n", "data = ds.sel(time=time).mean('time') - 273 # convert to celsius\n", "\n", "data.hvplot.image(x='lon', y='lat', z='air', title=time, clabel='T [C]')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Geographic Data\n", "\n", "By setting `coastline=True`, we can add a coastline feature to the plot and coerce it to the proper aspect." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "data.hvplot.image(coastline=True)" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }