{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tips and Tricks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This user guide contains an assorted collection of tips and tricks for minor features that don't have a suitable place in the rest of the documentation. Note that some of these tricks may be quick and convenient but not necessarily recommended practice. The list is currently quite short so if you have a neat tip to add to this guide, do suggest it to us on [gitter](https://gitter.im/ioam/holoviews)!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import holoviews as hv\n",
    "hv.extension('bokeh')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Magics can be parameterized"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The IPython magic syntax can be parameterized by building a string and using the ``$`` symbol. The following example outputs a bunch of files with parameterized output and filenames:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "val = 0.25\n",
    "formatter = \"fig='html' filename='./curve_{suffix}'\" \n",
    "magic_line = formatter.format(suffix=val+0.25)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now you can repeatedly run the following cell to change ``val`` and the filename that the output is saved to. You can repeatedly run a cell in Jupyter notebook using ``Ctrl + Enter``:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%output $magic_line\n",
    "val += 0.25\n",
    "magic_line = formatter.format(suffix=val+0.25)\n",
    "hv.Curve(([1,2,3],[1,2*val, 3]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now ``curve_0.5.html`` and any subsequent files should have been output in the current directory. On Unix systems you can remove these files by running ``rm curve_*.html`` in a code cell.\n",
    "\n",
    "Note this is just a convenience!  The robust and reproducible way to do this is to use an explicit renderer and loop as detailed in the [Plots and Renderers.ipynb](./Plots_and_Renderers.ipynb) user guide."
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
