{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Timeseries\n", "\n", "In many domains it is common to plot scalar values as a function of time (or other single dimensions). As long as the total number of datapoints is relatively low (in the tens of thousands, perhaps) and there are only a few separate curves involved, most plotting packages will do well. However, for longer or more frequent sampling, you'll be required to subsample your data before plotting, potentially missing important peaks or troughs in the data. And even just a few timeseries visualized together quickly run into highly misleading [overplotting](https://anaconda.org/jbednar/plotting_problems/notebook) issues, making the most recently plotted curves unduly prominent.\n", "\n", "For applications with many datapoints or when visualizing multiple curves, datashader provides a principled way to view *all* of your data. In this example, we will synthesize several time-series curves so that we know their properties, and then show how datashader can reveal them." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import xarray as xr\n", "import datashader as ds\n", "import datashader.transfer_functions as tf\n", "from collections import OrderedDict" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Create some fake timeseries data\n", "\n", "Here we create a fake time series signal, then generate many noisy versions of it. We will also add a couple of \"rogue\" lines, with different statistical properties, and see how well those stand out from the rest." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "x_range: (1456297053, 1456383453) y_range: (1456297053, 1456383453)\n" ] }, { "data": { "text/html": [ "
\n", " | Time | \n", "a | \n", "b | \n", "c | \n", "d | \n", "e | \n", "f | \n", "g | \n", "x | \n", "y | \n", "z | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|
99995 | \n", "1.456383e+09 | \n", "-43.266888 | \n", "-51.619471 | \n", "-42.867714 | \n", "-45.723507 | \n", "-47.229012 | \n", "-44.246641 | \n", "-46.509765 | \n", "-54.598808 | \n", "-44.922483 | \n", "-48.523868 | \n", "
99996 | \n", "1.456383e+09 | \n", "-42.733578 | \n", "-51.773237 | \n", "-42.984615 | \n", "-45.269990 | \n", "-45.537120 | \n", "-45.258385 | \n", "-44.763207 | \n", "-54.623914 | \n", "-45.116631 | \n", "-48.523325 | \n", "
99997 | \n", "1.456383e+09 | \n", "-42.614768 | \n", "-51.268256 | \n", "-42.201864 | \n", "-45.497689 | \n", "-46.426903 | \n", "-45.170198 | \n", "-45.393405 | \n", "-53.837847 | \n", "-44.981804 | \n", "-47.741589 | \n", "
99998 | \n", "1.456383e+09 | \n", "-44.684017 | \n", "-50.131985 | \n", "-42.204521 | \n", "-45.856321 | \n", "-48.606589 | \n", "-45.880804 | \n", "-46.653791 | \n", "-53.910759 | \n", "-43.639239 | \n", "-47.806325 | \n", "
99999 | \n", "1.456383e+09 | \n", "-46.027779 | \n", "-50.496361 | \n", "-42.615223 | \n", "-45.025591 | \n", "-46.462669 | \n", "-43.848973 | \n", "-47.319626 | \n", "-54.216269 | \n", "-45.546920 | \n", "-48.076312 | \n", "
\\n\"+\n", " \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n", " \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n", " \"
\\n\"+\n", " \"\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"
\\n\"+\n",
" \"