Created
January 16, 2023 16:51
-
-
Save Magnus167/bf8f6c732d38949e2d20fb9ba6c90293 to your computer and use it in GitHub Desktop.
tree maps for pydirstats
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": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"def fib(n, ns={0 : 0, 1 : 1}):\n", | |
" if n in ns:\n", | |
" return ns[n]\n", | |
" else:\n", | |
" ns[n] = fib(n-1, ns) + fib(n-2, ns)\n", | |
" return ns[n]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 14, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAgQAAAGMCAYAAAClCbq+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAbc0lEQVR4nO3deZydBX3v8e9km2SSzGRPCNlDNiTEQIBAIGwiCnJRFgVbEbQVqVZRq3jLq+pVC7XurYKlFwuKAqJoUDaVVQqyE0PIBiEhG0km2ySZTGY79w/b4aZhyXDOzEng/X698nrlWc7z/P6AzGee85znVBQKhUIAgDe1LuUeAAAoP0EAAAgCAEAQAAARBABABAEAEEEAAEQQAAARBABAkm57uuPKtScXfbJP3HJe0ccAymP2sU+XewTgdbh44uV7tJ8rBACAIAAABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQAAARBABABAEAEEEAAEQQA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Ccp+qbCe+6552XXz5s3r9hDAwCdpOgrBADAvs+TgwAAQQAACAIAIIIAAIggAAAiCACACAIAIIIAAIggAAAiCACACAIAIIIAAEjy/wAEEbw7LyLi1QAAAABJRU5ErkJggg==", | |
"text/plain": [ | |
"<Figure size 640x480 with 1 Axes>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"import matplotlib.pyplot as plt\n", | |
"import squarify \n", | |
"sizes = [fib(n) for n in range(1, 20)]\n", | |
"labels = [str(n) for n in range(1, 20)]\n", | |
"\n", | |
"squarify.plot(sizes=sizes, label=labels, alpha=.8 )\n", | |
"plt.axis('off')\n", | |
"plt.show()\n" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "py39", | |
"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.9.15" | |
}, | |
"orig_nbformat": 4, | |
"vscode": { | |
"interpreter": { | |
"hash": "cf99dc05b7c5a564d3a5b7593713bffb7a71b20bab76bb0d23424edfa9a5a797" | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment