diff --git a/notebooks/results/0.2.0-bunop-smarter_summary.ipynb b/notebooks/results/0.2.0-bunop-smarter_summary.ipynb index 03a64b7..37f9ed2 100644 --- a/notebooks/results/0.2.0-bunop-smarter_summary.ipynb +++ b/notebooks/results/0.2.0-bunop-smarter_summary.ipynb @@ -32,6 +32,7 @@ "metadata": {}, "outputs": [], "source": [ + "import os\n", "import json\n", "from collections import defaultdict\n", "from io import StringIO\n", @@ -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", @@ -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", @@ -187,7 +210,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "id": "74aab105-c016-4a98-9d7d-c30fe7d90830", "metadata": {}, "outputs": [], @@ -312,7 +335,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 14, "id": "58353886-f4d7-4a7e-973d-45c29aef015a", "metadata": {}, "outputs": [], @@ -357,7 +380,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 16, "id": "324b5381-5ff1-4b4c-ba23-569d77b11300", "metadata": {}, "outputs": [], @@ -442,7 +465,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 20, "id": "cf065c7b-797d-495b-a69f-9638e92a0454", "metadata": {}, "outputs": [], @@ -461,7 +484,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 21, "id": "0eabfc20-47bc-4de4-89a7-aebc569c70f1", "metadata": {}, "outputs": [], @@ -549,7 +572,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 25, "id": "ac4bff84-34c1-4526-898e-b6dfe93b1148", "metadata": {}, "outputs": [], @@ -579,7 +602,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 27, "id": "33dd743b", "metadata": {}, "outputs": [], @@ -626,7 +649,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 29, "id": "bfef48b4-efc2-4fee-b272-1d4cb6b486c1", "metadata": {}, "outputs": [], @@ -647,7 +670,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 30, "id": "d2a1c513-e5c0-4398-850f-80ab0f5b0087", "metadata": {}, "outputs": [], @@ -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()" ] @@ -706,7 +745,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 32, "id": "2102c053-8030-4878-8288-a0611c859e8a", "metadata": {}, "outputs": [], @@ -719,7 +758,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 33, "id": "30b33efc-b611-45c0-96a4-edaca2072ef1", "metadata": {}, "outputs": [], @@ -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()" ] @@ -763,7 +818,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 35, "id": "0d660d28", "metadata": {}, "outputs": [], @@ -808,7 +863,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 37, "id": "4a11f36e", "metadata": {}, "outputs": [], diff --git a/notebooks/results/utils.py b/notebooks/results/utils.py new file mode 100644 index 0000000..ecba53f --- /dev/null +++ b/notebooks/results/utils.py @@ -0,0 +1,5 @@ + +import os + +def get_notebook_results_path(): + return os.path.dirname(os.path.abspath(__file__))