Last active
May 17, 2017 14:16
-
-
Save EthanRosenthal/6694ce904ed48772172e9f47c26409b0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"plt.figure(figsize=(12, 12));\n", | |
"ax = plt.gca();\n", | |
"\n", | |
"table_width = 0.1\n", | |
"table_height = 0.15\n", | |
"x_offset = 0.1\n", | |
"y_offset = 0.05\n", | |
"x_step = 0.325\n", | |
"y_step = 0.25\n", | |
"fudge = .008\n", | |
"\n", | |
"y_name_step = table_height / 5\n", | |
"\n", | |
"for i, table in enumerate(tables):\n", | |
" # Tables will be in a 4 x 3 grid.\n", | |
" row = i % 4\n", | |
" col = int(np.floor(i / 4))\n", | |
" \n", | |
" # Find lower left corner of table.\n", | |
" x = x_offset + x_step * col\n", | |
" y = y_offset + y_step * row\n", | |
"\n", | |
" # Draw the table\n", | |
" rect = patches.Rectangle((x, y), \n", | |
" table_width, \n", | |
" table_height,\n", | |
" linewidth=1,\n", | |
" edgecolor=None,\n", | |
" facecolor='tab:brown')\n", | |
" ax.add_patch(rect)\n", | |
" \n", | |
" # Label the table\n", | |
" table_center = (x + table_width/2 - fudge, \n", | |
" y + table_height/2 - fudge)\n", | |
" \n", | |
" ax.annotate(table, \n", | |
" xy=table_center, \n", | |
" fontsize=20,\n", | |
" color='w', \n", | |
" weight='bold')\n", | |
" \n", | |
" # Who is sitting at the table?\n", | |
" seats = (seating.query('table_number == {}'.format(table))\n", | |
" .index)\n", | |
" seats_per_side = 5\n", | |
" if len(seats) == 8:\n", | |
" seats_per_side = 4\n", | |
" elif len(seats) > 10:\n", | |
" seats_per_side = 6\n", | |
"\n", | |
" # For each guest at the table,\n", | |
" # print their name around the edge\n", | |
" for j, name in enumerate(seats):\n", | |
" \n", | |
" table_col = int(np.floor(j / seats_per_side))\n", | |
" table_row = j % seats_per_side\n", | |
" \n", | |
" align = 'right' if table_col == 0 else 'left'\n", | |
" rotation = 45 if table_col == 0 else -45\n", | |
" \n", | |
" xy = (x + table_col*table_width, \n", | |
" y + table_row*y_name_step)\n", | |
" \n", | |
" if name in (bride, groom):\n", | |
" color = 'r'\n", | |
" else:\n", | |
" color = 'k'\n", | |
" \n", | |
" ax.annotate(name, \n", | |
" xy=xy,\n", | |
" rotation=rotation, \n", | |
" horizontalalignment=align,\n", | |
" color=color)\n", | |
" \n", | |
" \n", | |
"plt.axis('off')\n", | |
"plt.show()" | |
] | |
} | |
], | |
"metadata": { | |
"anaconda-cloud": {}, | |
"kernelspec": { | |
"display_name": "Python [conda root]", | |
"language": "python", | |
"name": "conda-root-py" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment