Created
October 2, 2020 12:56
-
-
Save sabopy/710c1927d471a17dcd04eb79fb8e1ec7 to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"%matplotlib widget\n", | |
"import numpy as np\n", | |
"import matplotlib.pyplot as plt\n", | |
"import matplotlib.ticker as ticker\n", | |
"plt.rcParams['font.size']=20\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"x = np.linspace(1,9,9)[:,np.newaxis]\n", | |
"y = np.linspace(1,9,9)[:,np.newaxis].T\n", | |
"kuku = x*y\n", | |
"kuku = kuku.flatten().astype(int)\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "bbaffb3ad6424aeb889af7c3a0e0adc8", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"text/plain": [ | |
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"\n", | |
"def enter_axes(event):\n", | |
" print('enter_axes', event.inaxes)\n", | |
" event.inaxes.patch.set_facecolor('w')\n", | |
" event.canvas.draw()\n", | |
"\n", | |
"def leave_axes(event):\n", | |
" print('leave_axes', event.inaxes)\n", | |
" event.inaxes.patch.set_facecolor('k')\n", | |
" event.canvas.draw()\n", | |
"\n", | |
"\n", | |
"fig,ax = plt.subplots(ncols=9,nrows=9,figsize=(8,8))\n", | |
"fig.suptitle('Multiplication table')\n", | |
"ax = ax.ravel()\n", | |
"[ax[i].set_facecolor('k') for i in range(len(ax))]\n", | |
"[ax[i].xaxis.set_major_locator(ticker.NullLocator()) for i in range(len(ax))]\n", | |
"[ax[i].yaxis.set_major_locator(ticker.NullLocator()) for i in range(len(ax))]\n", | |
"[ax[i].text(0.5, 0.5, str(kuku[i]), ha='center',va='center', transform=ax[i].transAxes) for i in range(len(ax))]\n", | |
"[ax[i].set_ylabel(str(kuku[i]),rotation=0,y=0.2,labelpad=10) for i in range(0,81,9)]\n", | |
"[ax[i].set_title(str(kuku[i])) for i in range(0,9,1)]\n", | |
"\n", | |
"fig.canvas.mpl_connect('axes_enter_event', enter_axes)\n", | |
"fig.canvas.mpl_connect('axes_leave_event', leave_axes)\n", | |
"\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"1.19.1\n" | |
] | |
} | |
], | |
"source": [ | |
"print(np.__version__)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"3.3.2\n" | |
] | |
} | |
], | |
"source": [ | |
"import matplotlib\n", | |
"print(matplotlib.__version__)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"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.7.8" | |
}, | |
"widgets": { | |
"application/vnd.jupyter.widget-state+json": { | |
"state": { | |
"57b280528a86440495d416baf2298939": { | |
"model_module": "@jupyter-widgets/base", | |
"model_module_version": "1.2.0", | |
"model_name": "LayoutModel", | |
"state": {} | |
}, | |
"6738379672c4458aa66377a06f6ea95c": { | |
"model_module": "jupyter-matplotlib", | |
"model_module_version": "^0.7.2", | |
"model_name": "ToolbarModel", | |
"state": { | |
"layout": "IPY_MODEL_57b280528a86440495d416baf2298939", | |
"toolitems": [ | |
[ | |
"Home", | |
"Reset original view", | |
"home", | |
"home" | |
], | |
[ | |
"Back", | |
"Back to previous view", | |
"arrow-left", | |
"back" | |
], | |
[ | |
"Forward", | |
"Forward to next view", | |
"arrow-right", | |
"forward" | |
], | |
[ | |
"Pan", | |
"Pan axes with left mouse, zoom with right", | |
"arrows", | |
"pan" | |
], | |
[ | |
"Zoom", | |
"Zoom to rectangle", | |
"square-o", | |
"zoom" | |
], | |
[ | |
"Download", | |
"Download plot", | |
"floppy-o", | |
"save_figure" | |
] | |
] | |
} | |
}, | |
"7828b87b103c4a568f6623e0019ffb44": { | |
"model_module": "@jupyter-widgets/base", | |
"model_module_version": "1.2.0", | |
"model_name": "LayoutModel", | |
"state": {} | |
}, | |
"e5fdc589a18a478bb47571c5c43bf3e4": { | |
"model_module": "jupyter-matplotlib", | |
"model_module_version": "^0.7.2", | |
"model_name": "MPLCanvasModel", | |
"state": { | |
"_cursor": "default", | |
"_figure_label": "Figure 1", | |
"_height": 480, | |
"_width": 640, | |
"layout": "IPY_MODEL_7828b87b103c4a568f6623e0019ffb44", | |
"toolbar": "IPY_MODEL_6738379672c4458aa66377a06f6ea95c", | |
"toolbar_position": "left" | |
} | |
} | |
}, | |
"version_major": 2, | |
"version_minor": 0 | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment