From fbc4942f29aa12ebeeddcd45005add66a8f94b6d Mon Sep 17 00:00:00 2001 From: Leah Wasser Date: Sun, 11 Aug 2024 14:09:52 -0600 Subject: [PATCH] fix: function altair --- .../pyOpenSci-peer-review-stats.ipynb | 162 ++++++++++++------ 1 file changed, 108 insertions(+), 54 deletions(-) diff --git a/review-metrics/pyOpenSci-peer-review-stats.ipynb b/review-metrics/pyOpenSci-peer-review-stats.ipynb index 76bc445..66bbebd 100644 --- a/review-metrics/pyOpenSci-peer-review-stats.ipynb +++ b/review-metrics/pyOpenSci-peer-review-stats.ipynb @@ -41,7 +41,8 @@ "from pyosmeta import ProcessIssues\n", "from pyosmeta.github_api import GitHubAPI\n", "\n", - "from functions import load_poppins_font, register_and_enable_poppins_theme\n", + "\n", + "\n", "\n", "pd.options.mode.chained_assignment = None\n", "pd.options.future.infer_string = True\n", @@ -49,6 +50,62 @@ "# Suppress all warnings\n", "warnings.filterwarnings(\"ignore\")\n", "\n", + "\n", + "def load_poppins_font():\n", + " \"\"\"Load the Poppins font from Google Fonts.\"\"\"\n", + " display(HTML(''))\n", + "\n", + "def poppins_theme():\n", + " \"\"\"Define the custom Poppins theme for Altair.\"\"\"\n", + " return {\n", + " 'config': {\n", + " 'title': {\n", + " 'fontSize': 20,\n", + " 'font': 'Poppins',\n", + " 'anchor': 'start',\n", + " 'color': 'black',\n", + " 'anchor': 'middle', # centered\n", + " 'fontWeight': 400,\n", + " 'dy': -20,\n", + " 'dx': 10\n", + " },\n", + " 'axis': {\n", + " 'labelFontSize': 12,\n", + " 'titleFontSize': 14,\n", + " 'titleFont': 'Poppins',\n", + " 'labelFont': 'Poppins',\n", + " 'labelFontSize': 14, \n", + " },\n", + " 'axisX': { # Configuration specifically for the x-axis\n", + " 'labelAngle': 0},\n", + " 'legend': {\n", + " 'labelFontSize': 12,\n", + " 'titleFontSize': 14,\n", + " 'titleFont': 'Poppins',\n", + " 'labelFont': 'Poppins'\n", + " },\n", + " 'bar': {\n", + " 'color': 'purple',\n", + " 'fill': 'purple'\n", + " },\n", + " 'line': {\n", + " 'color': 'purple'\n", + " },\n", + " 'view': {\n", + " 'height': 300,\n", + " 'width': 600, # Default chart width\n", + " 'padding': {\"top\": 190, \"left\": 10, \"right\": 10, \"bottom\": 90}\n", + " }\n", + " }\n", + " }\n", + "\n", + "def register_and_enable_poppins_theme():\n", + " \"\"\"Register and enable the Poppins theme in Altair.\"\"\"\n", + " alt.themes.register('poppins_theme', poppins_theme)\n", + " alt.themes.enable('poppins_theme')\n", + "\n", + "\n", + "\n", "# https://github.com/ryantam626/jupyterlab_code_formatter" ] }, @@ -351,7 +408,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 9, "metadata": { "editable": true, "slideshow": { @@ -367,23 +424,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -629,7 +686,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 12, "metadata": { "editable": true, "slideshow": { @@ -645,23 +702,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -1197,23 +1254,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "" ], "text/plain": [ @@ -1525,9 +1582,6 @@ " \"Nov\",\n", " \"Dec\",\n", " ],\n", - " axis=alt.Axis(\n", - " labelExpr=\"if(datum.value in ['Jan', 'Apr', 'Jul', 'Oct'], datum.value, '')\"\n", - " ),\n", " ),\n", " y=\"count\",\n", " tooltip=[\"month\", \"count\"],\n", @@ -1659,23 +1713,23 @@ "text/html": [ "\n", "\n", - "
\n", + "
\n", "