Alberto Pepe added file figures/open-access-costs/open-access-costs-notebook.ipynb  almost 10 years ago

Commit id: 8afa017a37a005760296ade2982e1224448d191f

deletions | additions      

         

{  "metadata": {  "name": "open-access-costs-notebook"  },  "nbformat": 3,  "nbformat_minor": 0,  "worksheets": [  {  "cells": [  {  "cell_type": "markdown",  "metadata": {},  "source": "# Welcome to this IPython notebook on Authorea! \nThe code below when executed will generate the plot you see at https://authorea.com/7388/. In order to execute it, click anywhere in the cell below and then press Shift+Enter. The image should appear below. Try to change some parameters or the title/axis to change the figure on the fly. Like the figure? You can also download the IPython notebook and take it home with you! Please note that the IPython functionality in Authorea expires if you don't use it for more than 5 minutes. "  },  {  "cell_type": "code",  "collapsed": false,  "input": "from datetime import datetime, date, time\nimport sys\nimport matplotlib.dates as mdates\nimport numpy as np\n\nimport pandas as pd\nfrom pandas import Series, DataFrame, Panel\n\nimport matplotlib.pyplot as plt\nimport matplotlib as mpl\nmpl.rc('figure', figsize=(10, 8)) \n\nrng = pd.DateRange('5/5/2014', periods=55, freq='M')\n#the following for a more recent version of pandas\n#rng = pd.date_range('5/5/2014', periods=55, freq='M')\n\nprices = [ 1523.18, 1633.49, 1419.78, 1247.74, 1251.74, 1277.37, 1285.67, 1292.84, 1282.84, 1297.68, 1299.48, 1309.07, 1344.11, 1384.62, 1419.85, 1450.59, 1480.82, 1509.45,\n 1537.74, 1567.09, 1531.59, 1490.12, 1508.2 , 1465.19, 1465.19, 1465.19, 1465.19, 1476.92, 1506.75, 1533.04,\n 1508.57, 1530.86, 1530.86, 1530.86, 1530.86, 1510.46, 1516.16, 1524.35, 1504.33, 1512.53, 1512.53, 1512.53,\n 1512.53, 1494.21, 1498.47, 1524.6 , 1547.87, 1527.64, 1527.64, 1527.64, 1527.64, 1530.98, 1558.73, 1544.17, 1568.89]\n\npredicted_error = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.5,1,1,2,2,3,3,5,5,5,5,10,10,10,10,10,10,10,10,10,10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 25, 30, 40, 40, 40, 40, 60, 80, 80, 100]\n\nfig = plt.figure()\nfig.suptitle('Cost of publishing an open access paper (fake data!)', fontsize=16)\nax = fig.add_subplot(111)\nax.set_xlabel('Date')\nax.set_ylabel('Price with predicted error range, in US dollars')\nmyFmt = mdates.DateFormatter('%Y-%m')\nax.xaxis.set_major_formatter(myFmt)\nax.grid(True)\nplt.plot(rng, prices, 'k', color='#CACACA')\nplt.fill_between(rng, np.add(prices,predicted_error), np.subtract(prices,predicted_error), alpha=0.2, edgecolor='#FF9848', facecolor='#FF9848')\n\n#the following is for test average\nplt.axhline(y=1489, xmin=0, xmax=1, linewidth=6, color='#ff8910', alpha=0.6)\nax.annotate('10-year average: $1489', xy=(rng[6], 1485))\n\nplt.show()",  "language": "python",  "metadata": {},  "outputs": [],  "prompt_number": 36  },  {  "cell_type": "code",  "collapsed": false,  "input": "",  "language": "python",  "metadata": {},  "outputs": []  }  ],  "metadata": {}  }  ]  }