{ "cells": [ { "cell_type": "markdown", "id": "72cb0157-56e8-4420-b051-dd15b1005c71", "metadata": {}, "source": [ "# Marie as a firstname over time and departements" ] }, { "cell_type": "code", "execution_count": 1, "id": "0905b8e4-6537-4f60-97b9-a973b2678e61", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.cm as cm\n", "import matplotlib.pyplot as plt\n", "import matplotlib.colors as mcolors\n", "\n", "from pynsee.download import download_file, get_file_list\n", "from pynsee.geodata import GeoFrDataFrame, get_geodata_list, get_geodata" ] }, { "cell_type": "code", "execution_count": 2, "id": "25ef85ba-4648-420a-83e0-5687f06aed5b", "metadata": {}, "outputs": [], "source": [ "import logging\n", "import sys\n", "logging.basicConfig(stream=sys.stdout,\n", " level=logging.INFO, \n", " format=\"%(message)s\")" ] }, { "cell_type": "code", "execution_count": 2, "id": "ffe525fc-33e7-4966-a30b-7d6b92b9403e", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 27%|██▋ | 3.42M/12.8M [00:00<00:01, 6.06MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 31%|███▏ | 4.01M/12.8M [00:00<00:01, 5.89MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 38%|███▊ | 4.88M/12.8M [00:00<00:01, 6.80MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 43%|████▎ | 5.55M/12.8M [00:00<00:01, 6.43MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 48%|████▊ | 6.18M/12.8M [00:01<00:01, 5.61MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 53%|█████▎ | 6.73M/12.8M [00:01<00:01, 4.77MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 56%|█████▋ | 7.22M/12.8M [00:01<00:02, 2.34MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 59%|█████▉ | 7.58M/12.8M [00:02<00:03, 1.39MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 61%|██████▏ | 7.85M/12.8M [00:02<00:04, 1.20MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 63%|██████▎ | 8.06M/12.8M [00:03<00:04, 1.10MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 64%|██████▍ | 8.23M/12.8M [00:03<00:04, 1.02MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 66%|██████▌ | 8.43M/12.8M [00:03<00:04, 1.13MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 68%|██████▊ | 8.65M/12.8M [00:03<00:03, 1.30MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 69%|██████▉ | 8.83M/12.8M [00:03<00:03, 1.28MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 70%|███████ | 8.98M/12.8M [00:03<00:03, 1.11MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 73%|███████▎ | 9.35M/12.8M [00:04<00:02, 1.59MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 80%|███████▉ | 10.2M/12.8M [00:04<00:00, 3.08MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 87%|████████▋ | 11.1M/12.8M [00:04<00:00, 4.45MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 91%|█████████ | 11.6M/12.8M [00:04<00:00, 2.25MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 94%|█████████▍| 12.0M/12.8M [00:05<00:00, 1.42MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 97%|█████████▋| 12.3M/12.8M [00:05<00:00, 1.22MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 98%|█████████▊| 12.6M/12.8M [00:06<00:00, 1.10MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: 100%|█████████▉| 12.8M/12.8M [00:06<00:00, 1.12MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: : 12.9MiB [00:06, 978kiB/s] " ] }, { "name": "stderr", "output_type": "stream", "text": [ "Downloading: : 13.0MiB [00:06, 2.02MiB/s]" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "/home/coder/local/bin/conda/envs/basesspcloud/lib/python3.10/site-packages/pynsee/download/_download_store_file.py:68: UserWarning: File in insee.fr modified or corrupted during download\n", " warnings.warn(\"File in insee.fr modified or corrupted during download\")" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Extracting: 0%| | 0.00/76.3M [00:00" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# make plot\n", "\n", "fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(12, 12))\n", "axes = axes.flatten()\n", "\n", "normalize = mcolors.Normalize(vmin=datamap.pct.min(), vmax=datamap.pct.max())\n", "colormap = cm.jet\n", "\n", "plt.suptitle(\"Percentage of new female babies whose name is Marie\", x = 0.3, y = 0.9,\n", " horizontalalignment= 'left',\n", " fontsize = 12, fontweight='bold')\n", "\n", "for a, ax in zip(np.unique(datamap.annais.values), axes):\n", " ax.set_axis_off()\n", " dt = datamap[datamap.annais == a]\n", " p = dt.plot(column='pct', ax=ax, cmap=colormap, norm=normalize)\n", " ax.set_title(a)\n", " \n", "bbox = ax.get_position() \n", "cax = fig.add_axes([bbox.x1 + 0.01, bbox.y0 + 0.2, 0.01, bbox.height])\n", " \n", "fig.colorbar(cm.ScalarMappable(norm=normalize, cmap=colormap), cax=cax)\n", "plt.subplots_adjust(hspace=-0.2, wspace=-0.1)\n", "\n", "plt.show()" ] } ], "metadata": { "jupytext": { "text_representation": { "extension": ".qmd", "format_name": "quarto", "format_version": "1.0", "jupytext_version": "1.13.8" } }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.12.11" } }, "nbformat": 4, "nbformat_minor": 5 }