{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"# Charts Tutorial\n",
"
\n",
"The python [**Charts**](https://github.com/arnoutaertgeerts/python-highcharts) library enables you to use the amazing [Highcharts](http://www.highcharts.com/) javascript library in your Python code to create beautiful and interactive charts. The library is structured in such a way that anything you can do with Highcharts, you can do with **Charts**... Even right in your IPython Notebook!\n",
"\n",
"**Contents**\n",
"- [Installation](#Installation)\n",
"- [Data configuration](#Data-configuration)\n",
"- [Variable searcher and settings editor](#Variable-searcher-and-settings-editor)\n",
"- [Chart options](#Chart-options)\n",
"- [Chart types](#Chart-types)\n",
"- [Async plots](http://nbviewer.ipython.org/github/arnoutaertgeerts/python-highcharts/blob/master/Async%20plotting.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Installation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"All you need to do to get started is download the library using pip:\n",
"\n",
" pip install charts\n",
" \n",
"Import the libary in Python to get started:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Server running in the folder /Users/arnoutaertgeerts/Projects/python-highcharts at 127.0.0.1:51780\n"
]
}
],
"source": [
"import charts"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Chart has two main functions which essentialy do the same thing, plot a chart: \n",
"\n",
"- `charts.plot(series, options)`\n",
"- `charts.plotasync(series, options)`\n",
"\n",
"In this quickstart we will discuss the `plot()` method and leave `plotasync()` for a different notebook. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data configuration\n",
"\n",
"In *charts*, each data serie you want to plot has to have a name. You can specify this name in three ways:\n",
"\n",
"1. If you want to plot a single series, you can use the `name` argument: \n",
"```\n",
"charts.plot(data, name='My list')\n",
"```\n",
"2. If you want to plot multiple series, you have to use the **series** format. This format is a dictionary containing two properties: data and name: \n",
"```\n",
"charts.plot(dict(data=data, name='My series'))\n",
"``` \n",
"To plot multiple series in one chart, just create a list of the series dictionaries: \n",
"```\n",
"charts.plot([series])\n",
"```\n",
"3. You can also use a pandas dataframe: \n",
"```\n",
"charts.plot(dataframe)\n",
"```\n",
"\n",
"The data itself has to be one of these two options:\n",
"\n",
"1. A single list (or numpy array): \n",
"```\n",
"data = [1,2,5,9,6,3,4,8]\n",
"```\n",
"\n",
"2. A list containing x,y pairs: \n",
"```\n",
"data = [[1,8],[2,7],[3,4],[4,3],[5,9],[6,0],[7,10],[8,5]]\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Lets try this for the 3 different methods. Note that we add the option `show='inline'` to show the charts inline in the notebook:\n",
"\n",
"1) A single series with the name argument"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"\n",
"\n",
"