Last active
August 29, 2015 14:03
-
-
Save empet/b1b5a061219ad972acce to your computer and use it in GitHub Desktop.
Romanian team results at the International Mathematical Olympiads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:d538002b807add8caef4d3acb4ac33c667c20bbdd17699c106ecae09b6a0a15e" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "heading", | |
"level": 2, | |
"metadata": {}, | |
"source": [ | |
"Romanian team results at the International Mathematical Olympiads" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%matplotlib inline\n", | |
"import matplotlib.pyplot as plt\n", | |
"import pandas as pd\n", | |
"import numpy as np" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 1 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"years=[i for i in range(1959, 1980)]+ [j for j in range(1981, 2015)]# IMO was not held in 1980" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 2 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"medals=np.loadtxt('RoImo.txt')#data from http://www.imo-official.org/" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 3 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"L=len(years)\n", | |
"Rez=np.zeros((L,4), int)\n", | |
"Rez[:,0]=years\n", | |
"Rez[:,1:4]=medals" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"colors=['#D9D919', '#E6E8FA', '#A67D3D'] #bright gold, silver, bronze\n" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 5 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"import plotly.plotly as py\n", | |
"from plotly.graph_objs import *\n", | |
"\n", | |
"py.sign_in(\"empet\", \"my_api_key\")\n" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 8 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"Gold = Bar(\n", | |
" x=Rez[:,0],\n", | |
" y=Rez[:,1],\n", | |
" name='Gold Medals',\n", | |
" marker=Marker(\n", | |
" color=colors[0]\n", | |
" )\n", | |
")\n", | |
"Silver = Bar(\n", | |
" x=Rez[:,0],\n", | |
" y=Rez[:,2],\n", | |
" name='Silver Medals',\n", | |
" marker=Marker(\n", | |
" color=colors[1]\n", | |
" )\n", | |
")\n", | |
"Bronze = Bar(\n", | |
" x=Rez[:,0],\n", | |
" y=Rez[:,3],\n", | |
" name='Bronze Medals',\n", | |
" marker=Marker(\n", | |
" color=colors[2]\n", | |
" )\n", | |
")\n", | |
"data = Data([Gold, Silver, Bronze])\n", | |
"anno_text=\"Data Source: International Mathematical Olympiad\\\n", | |
" <a href='http://www.imo-official.org/results.aspx'>[1]</a>\"\n", | |
"layout = Layout(title='International Mathematical Olympiad Medals for Romanian Teams',\n", | |
" xaxis=XAxis(\n", | |
" tickfont=Font(\n", | |
" size=14,\n", | |
" color='rgb(107, 107, 107)'\n", | |
" )\n", | |
" ),\n", | |
" yaxis=YAxis(\n", | |
" title='Number of Medals',\n", | |
" titlefont={'color': 'rgb(107, 107, 107)', 'size': 16},\n", | |
" tickfont=Font(\n", | |
" size=14,\n", | |
" color='rgb(107, 107, 107)'\n", | |
" )\n", | |
" ),\n", | |
" legend=Legend(\n", | |
" x=0,\n", | |
" y=1.2,\n", | |
" bgcolor='rgba(255, 255, 255, 0)',\n", | |
" bordercolor='rgba(255, 255, 255, 0)'\n", | |
" ),\n", | |
" \n", | |
" annotations=Annotations([\n", | |
" Annotation(\n", | |
" x=0.2000000000000038,\n", | |
" y=0.43,\n", | |
" xref='paper',\n", | |
" yref='paper',\n", | |
" text=anno_text,\n", | |
"\n", | |
"\n", | |
" font=Font(\n", | |
" family='',\n", | |
" size=0,\n", | |
" color=''\n", | |
" ),\n", | |
" align='center',\n", | |
" showarrow=True,\n", | |
" arrowhead=1,\n", | |
" arrowsize=1,\n", | |
" arrowwidth=0,\n", | |
" arrowcolor='rgba(68, 68, 68, 0)',\n", | |
" ax=-23,\n", | |
" ay=179.98332977294922,\n", | |
" bordercolor='',\n", | |
" borderwidth=1,\n", | |
" borderpad=1,\n", | |
" bgcolor='rgba(0,0,0,0)',\n", | |
" opacity=1,\n", | |
" xanchor='auto',\n", | |
" yanchor='auto',\n", | |
" tag=''\n", | |
" )\n", | |
" ]),\n", | |
" margin=Margin(\n", | |
" l=80,\n", | |
" r=40,\n", | |
" b=85,\n", | |
" t=110,\n", | |
" pad=0,\n", | |
" autoexpand=True\n", | |
" ),\n", | |
" barmode='group',\n", | |
" bargap=0.15,\n", | |
" bargroupgap=0.15,\n", | |
" autosize=False,\n", | |
" width=800,\n", | |
" height=450\n", | |
")\n", | |
"fig = Figure(data=data, layout=layout)\n", | |
"py.iplot(fig, filename='IMOMedalsRo')" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~empet/20\" height=\"525\" width=\"100%\"></iframe>" | |
], | |
"metadata": {}, | |
"output_type": "display_data", | |
"text": [ | |
"<IPython.core.display.HTML at 0xc711f98>" | |
] | |
} | |
], | |
"prompt_number": 27 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"print anno_text" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"Data: International Mathematical Olympiad <br>Source: <a href='http://www.imo-official.org/results.aspx'>[1]</a>\n" | |
] | |
} | |
], | |
"prompt_number": 11 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"G=np.sum(Rez[:,1])#sum of gold medals\n", | |
"S=np.sum(Rez[:,2])\n", | |
"B=np.sum(Rez[:,3])" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [], | |
"prompt_number": 10 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"GoldT = Bar(\n", | |
" x=[2014],\n", | |
" y=[G],\n", | |
" name='Gold Medals',\n", | |
" marker=Marker(\n", | |
" color=colors[0]\n", | |
" )\n", | |
")\n", | |
"SilverT = Bar(\n", | |
" x=[2014],\n", | |
" y=[S],\n", | |
" name='Silver Medals',\n", | |
" marker=Marker(\n", | |
" color=colors[1]\n", | |
" )\n", | |
")\n", | |
"BronzeT = Bar(\n", | |
" x=[2014],\n", | |
" y=[B],\n", | |
" name='Bronze Medals',\n", | |
" marker=Marker(\n", | |
" color=colors[2]\n", | |
" )\n", | |
")\n", | |
"data = Data([GoldT, SilverT, BronzeT])\n", | |
"\n", | |
"layout = Layout(title='Total Number of Medals for Romanian Teams at IMO, between 1959-2014',\n", | |
" xaxis=XAxis(\n", | |
" tickfont=Font(\n", | |
" size=14,\n", | |
" color='rgb(107, 107, 107)'\n", | |
" )\n", | |
" ),\n", | |
" yaxis=YAxis(\n", | |
" title='Number of Medals',\n", | |
" titlefont={'color': 'rgb(107, 107, 107)', 'size': 16},\n", | |
" tickfont=Font(\n", | |
" size=14,\n", | |
" color='rgb(107, 107, 107)'\n", | |
" )\n", | |
" ),\n", | |
" legend=Legend(\n", | |
" x=0,\n", | |
" y=1.0,\n", | |
" bgcolor='rgba(255, 255, 255, 0)',\n", | |
" bordercolor='rgba(255, 255, 255, 0)'\n", | |
" ),\n", | |
" barmode='group',\n", | |
" bargap=0.15,\n", | |
" bargroupgap=0.15\n", | |
")\n", | |
"fig = Figure(data=data, layout=layout)\n", | |
"py.iplot(fig, filename='NrIMOMedalsRo')" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\"seamless=\"seamless\" src=\"https://plot.ly/~empet/21\" height=\"525\" width=\"100%\"></iframe>" | |
], | |
"metadata": {}, | |
"output_type": "display_data", | |
"text": [ | |
"<IPython.core.display.HTML at 0xaf98630>" | |
] | |
} | |
], | |
"prompt_number": 11 | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"E Petrisor, UPT" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"from IPython.core.display import HTML\n", | |
"def css_styling():\n", | |
" styles = open(\"./styles/custom.css\", \"r\").read()\n", | |
" return HTML(styles)\n", | |
"css_styling()\n" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"html": [ | |
"<style>\n", | |
" @font-face {\n", | |
" font-family: \"Computer Modern\";\n", | |
" src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');\n", | |
" }\n", | |
" div.cell{\n", | |
" width:800px;\n", | |
" margin-left:16% !important;\n", | |
" margin-right:auto;\n", | |
" }\n", | |
" h1 {\n", | |
" font-family: Helvetica, serif;\n", | |
" }\n", | |
" h4{\n", | |
" margin-top:12px;\n", | |
" margin-bottom: 3px;\n", | |
" }\n", | |
" div.text_cell_render{\n", | |
" font-family: Computer Modern, \"Helvetica Neue\", Arial, Helvetica, Geneva, sans-serif;\n", | |
" line-height: 145%;\n", | |
" font-size: 130%;\n", | |
" width:800px;\n", | |
" margin-left:auto;\n", | |
" margin-right:auto;\n", | |
" }\n", | |
" .CodeMirror{\n", | |
" font-family: \"Source Code Pro\", source-code-pro,Consolas, monospace;\n", | |
" }\n", | |
" .prompt{\n", | |
" display: None;\n", | |
" }\n", | |
" .text_cell_render h5 {\n", | |
" font-weight: 300;\n", | |
" font-size: 22pt;\n", | |
" color: #4057A1;\n", | |
" font-style: italic;\n", | |
" margin-bottom: .5em;\n", | |
" margin-top: 0.5em;\n", | |
" display: block;\n", | |
" }\n", | |
" \n", | |
" .warning{\n", | |
" color: rgb( 240, 20, 20 )\n", | |
" } \n", | |
"</style>\n", | |
"<script>\n", | |
" MathJax.Hub.Config({\n", | |
" TeX: {\n", | |
" extensions: [\"AMSmath.js\"]\n", | |
" },\n", | |
" tex2jax: {\n", | |
" inlineMath: [ ['$','$'], [\"\\\\(\",\"\\\\)\"] ],\n", | |
" displayMath: [ ['$$','$$'], [\"\\\\[\",\"\\\\]\"] ]\n", | |
" },\n", | |
" displayAlign: 'center', // Change this to 'center' to center equations.\n", | |
" \"HTML-CSS\": {\n", | |
" styles: {'.MathJax_Display': {\"margin\": 4}}\n", | |
" }\n", | |
" });\n", | |
"</script>\n" | |
], | |
"metadata": {}, | |
"output_type": "pyout", | |
"prompt_number": 12, | |
"text": [ | |
"<IPython.core.display.HTML at 0xc541668>" | |
] | |
} | |
], | |
"prompt_number": 12 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment