Skip to content

Commit

Permalink
💄 increase label size of sheep and goats counts by countries
Browse files Browse the repository at this point in the history
  • Loading branch information
bunop committed Oct 16, 2024
1 parent 2c8a35b commit 557deeb
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 17 deletions.
89 changes: 72 additions & 17 deletions notebooks/results/0.2.0-bunop-smarter_summary.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import json\n",
"from collections import defaultdict\n",
"from io import StringIO\n",
Expand All @@ -45,6 +46,17 @@
"from src.features.smarterdb import global_connection, Dataset, SampleSheep, SampleGoat, Country\n",
"from src.features.utils import countries\n",
"\n",
"# custom module to determine the path of this notebook\n",
"from utils import get_notebook_results_path"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "902c7ef0",
"metadata": {},
"outputs": [],
"source": [
"conn = global_connection()\n",
"\n",
"def fix_id(df: pd.DataFrame):\n",
Expand All @@ -65,6 +77,17 @@
" return df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eb400f2c",
"metadata": {},
"outputs": [],
"source": [
"os.chdir(get_notebook_results_path())\n",
"os.getcwd()"
]
},
{
"cell_type": "markdown",
"id": "13db17a0-7abb-4288-ba0d-d48cdb7f1477",
Expand Down Expand Up @@ -187,7 +210,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"id": "74aab105-c016-4a98-9d7d-c30fe7d90830",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -312,7 +335,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 14,
"id": "58353886-f4d7-4a7e-973d-45c29aef015a",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -357,7 +380,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 16,
"id": "324b5381-5ff1-4b4c-ba23-569d77b11300",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -442,7 +465,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 20,
"id": "cf065c7b-797d-495b-a69f-9638e92a0454",
"metadata": {},
"outputs": [],
Expand All @@ -461,7 +484,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 21,
"id": "0eabfc20-47bc-4de4-89a7-aebc569c70f1",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -549,7 +572,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 25,
"id": "ac4bff84-34c1-4526-898e-b6dfe93b1148",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -579,7 +602,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 27,
"id": "33dd743b",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -626,7 +649,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 29,
"id": "bfef48b4-efc2-4fee-b272-1d4cb6b486c1",
"metadata": {},
"outputs": [],
Expand All @@ -647,7 +670,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 30,
"id": "d2a1c513-e5c0-4398-850f-80ab0f5b0087",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -684,13 +707,29 @@
"fig, ax = plt.subplots(figsize=(20,20))\n",
"divider = make_axes_locatable(ax)\n",
"cax = divider.append_axes(\"right\", size=\"5%\", pad=0.1)\n",
"\n",
"plot = sheep_by_country.plot(\n",
" column='count',\n",
" ax=ax,\n",
" legend=True,\n",
" cax=cax,\n",
" missing_kwds={\"color\": \"lightgrey\", \"label\": \"Missing values\"})\n",
"_ = ax.set_title(\"SMARTER Sheep Samples by country\")\n",
" missing_kwds={\"color\": \"lightgrey\", \"label\": \"Missing values\"}\n",
")\n",
"\n",
"# Set the title with increased font size\n",
"ax.set_title(\"SMARTER Sheep Samples by Country\", fontsize=20)\n",
"\n",
"# Set axis labels with increased font size\n",
"ax.set_xlabel(\"Longitude\", fontsize=15)\n",
"ax.set_ylabel(\"Latitude\", fontsize=15)\n",
"\n",
"# Increase the size of the tick labels on both axes\n",
"ax.tick_params(axis='both', labelsize=15)\n",
"\n",
"# Increase the font size of the colorbar labels\n",
"cbar = plt.gcf().get_axes()[-1] # Get the colorbar axes\n",
"cbar.tick_params(labelsize=15) # Set the font size of the colorbar ticks\n",
"\n",
"plt.savefig('sheep-by-country.png', dpi=300, bbox_inches='tight')\n",
"plt.show()"
]
Expand All @@ -706,7 +745,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 32,
"id": "2102c053-8030-4878-8288-a0611c859e8a",
"metadata": {},
"outputs": [],
Expand All @@ -719,7 +758,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 33,
"id": "30b33efc-b611-45c0-96a4-edaca2072ef1",
"metadata": {},
"outputs": [],
Expand All @@ -738,13 +777,29 @@
"fig, ax = plt.subplots(figsize=(20,20))\n",
"divider = make_axes_locatable(ax)\n",
"cax = divider.append_axes(\"right\", size=\"5%\", pad=0.1)\n",
"\n",
"plot = goats_by_country.plot(\n",
" column='count',\n",
" ax=ax,\n",
" legend=True,\n",
" cax=cax,\n",
" missing_kwds={\"color\": \"lightgrey\", \"label\": \"Missing values\"})\n",
"_ = ax.set_title(\"SMARTER Goat Samples by country\")\n",
" missing_kwds={\"color\": \"lightgrey\", \"label\": \"Missing values\"}\n",
")\n",
"\n",
"# Set the title with increased font size\n",
"ax.set_title(\"SMARTER Goat Samples by Country\", fontsize=20)\n",
"\n",
"# Set axis labels with increased font size\n",
"ax.set_xlabel(\"Longitude\", fontsize=15)\n",
"ax.set_ylabel(\"Latitude\", fontsize=15)\n",
"\n",
"# Increase the size of the tick labels on both axes\n",
"ax.tick_params(axis='both', labelsize=15)\n",
"\n",
"# Increase the font size of the colorbar labels\n",
"cbar = plt.gcf().get_axes()[-1] # Get the colorbar axes\n",
"cbar.tick_params(labelsize=15) # Set the font size of the colorbar ticks\n",
"\n",
"plt.savefig('goat-by-country.png', dpi=300, bbox_inches='tight')\n",
"plt.show()"
]
Expand All @@ -763,7 +818,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 35,
"id": "0d660d28",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -808,7 +863,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 37,
"id": "4a11f36e",
"metadata": {},
"outputs": [],
Expand Down
5 changes: 5 additions & 0 deletions notebooks/results/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

import os

def get_notebook_results_path():
return os.path.dirname(os.path.abspath(__file__))

0 comments on commit 557deeb

Please sign in to comment.