{{ message }}

Instantly share code, notes, and snippets.

# pascal-schetelat/gist:8382651

Last active Aug 13, 2019
Slope graph tutorial
This file has been truncated, but you can view the full file.
 { "metadata": { "name": "slopeGraphs" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": "## E. Tufte Slope Graphs contest " }, { "cell_type": "markdown", "metadata": {}, "source": "So here is my entry for the slope Graph contest. (You can find the initial bounty description [here](http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0003nk) )\n\n## Installation\n\n### Dependancies \n\nThis script is written in Python and relies on Numpy, Pandas and Matplotlib. \nThe easiest way to have a clean and robust install is to download one the great Scientific Python distribution, namely : \n\n* [Anaconda](https://store.continuum.io/cshop/anaconda/)\n* [Canopy](https://www.enthought.com/products/canopy/)\n* [Python(x,y)](https://code.google.com/p/pythonxy/)\n\nEverything you'll need is included. I personally use Anaconda from the guys at Continuum Analytics. All of them should work on Linux, Windows and Mac. \n\n### Sources\n\n1. Grab the sources at https://github.com/pascal-schetelat/Slope\n\n2. Launch Spyder, the Scientific python IDE bundled with Anaconda\n\n3. Set the Spyder working directory where plotSlope.py is and import it in the console : \npython\n >>> from plotSlope import slope\n >>> import pandas as pd\n \nYou are good to go. \n\n" }, { "cell_type": "markdown", "metadata": {}, "source": "\n## Interactive example " }, { "cell_type": "code", "collapsed": false, "input": "# Initial import. Load code to the console\nfrom plotSlope import slope\nimport pandas as pd\nimport os\n", "language": "python", "metadata": {}, "outputs": [], "prompt_number": 14 }, { "cell_type": "code", "collapsed": false, "input": "# Load data from a csv file using pandas and display it \ndata = pd.read_csv(os.path.join('Data','EU_GDP_2007_2013.csv'),index_col=0,na_values='-')\ndata.head()/1000", "language": "python", "metadata": {}, "outputs": [ { "html": "
\n\n
2007200820092010201120122013
\n \n \n \n \n \n \n \n \n \n \n \n
Austria 274.0198 282.7460 274.8182 286.1973 300.8913 310.1333 322.1904
Belgium 335.6100 346.1300 340.3980 354.3780 370.4364 381.7799 396.2738
Bulgaria 30.7724 35.4305 34.9328 36.0335 38.9899 NaN NaN
Croatia 43.3804 47.7602 45.6661 45.8992 46.0216 46.7810 48.1752
Cyprus 15.9015 17.1571 16.8535 17.3336 17.9286 18.4096 19.1675