Laura Wagner commited on
Commit
605d40b
·
1 Parent(s): 47cec89

added fig s12 code

Browse files
jupyter_notebooks/0_Scraping_model_metadata.ipynb CHANGED
@@ -246,7 +246,7 @@
246
  },
247
  {
248
  "cell_type": "code",
249
- "execution_count": null,
250
  "id": "3f95b4ba-5742-4268-b2e8-de9145faf495",
251
  "metadata": {
252
  "execution": {
@@ -257,7 +257,15 @@
257
  "shell.execute_reply.started": "2025-02-08T19:37:58.117369Z"
258
  }
259
  },
260
- "outputs": [],
 
 
 
 
 
 
 
 
261
  "source": [
262
  "get_model_metadata()"
263
  ]
 
246
  },
247
  {
248
  "cell_type": "code",
249
+ "execution_count": 14,
250
  "id": "3f95b4ba-5742-4268-b2e8-de9145faf495",
251
  "metadata": {
252
  "execution": {
 
257
  "shell.execute_reply.started": "2025-02-08T19:37:58.117369Z"
258
  }
259
  },
260
+ "outputs": [
261
+ {
262
+ "name": "stdout",
263
+ "output_type": "stream",
264
+ "text": [
265
+ "Failed to fetch data: HTTP 500\n"
266
+ ]
267
+ }
268
+ ],
269
  "source": [
270
  "get_model_metadata()"
271
  ]
jupyter_notebooks/SuppM_Figure_S12_asset_types.ipynb ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "c0d18a6a",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": [
10
+ "import pandas as pd\n",
11
+ "import matplotlib.pyplot as plt\n",
12
+ "from matplotlib.ticker import FuncFormatter\n",
13
+ "from pathlib import Path"
14
+ ]
15
+ },
16
+ {
17
+ "cell_type": "code",
18
+ "execution_count": null,
19
+ "id": "98d25755",
20
+ "metadata": {},
21
+ "outputs": [],
22
+ "source": [
23
+ "current_dir = Path.cwd()\n",
24
+ "\n",
25
+ "def sortByFrequency_model_types_csv(csv_path, output_svg_path):\n",
26
+ " hatch_pattern = '\\\\\\\\\\\\\\\\\\\\\\\\' # Hatch pattern for the bars\n",
27
+ "\n",
28
+ " # Read the CSV file\n",
29
+ " df = pd.read_csv(csv_path)\n",
30
+ "\n",
31
+ " if 'type' not in df.columns:\n",
32
+ " return \"The CSV file does not contain a 'type' column.\"\n",
33
+ "\n",
34
+ " # Count the occurrences of each model type\n",
35
+ " type_counts = df['type'].value_counts().reset_index()\n",
36
+ " type_counts.columns = ['Type', 'Count']\n",
37
+ " total = type_counts['Count'].sum()\n",
38
+ " type_counts['Percentage'] = (type_counts['Count'] / total * 100).round(2)\n",
39
+ "\n",
40
+ " # Sort the data in ascending order\n",
41
+ " type_counts = type_counts.sort_values(by='Count', ascending=True)\n",
42
+ "\n",
43
+ " # Plotting\n",
44
+ " plt.figure(figsize=(10, 3.5))\n",
45
+ " bars = plt.barh(type_counts['Type'], type_counts['Count'], color='white', hatch=hatch_pattern, edgecolor='coral')\n",
46
+ " plt.xlabel('Counts', fontweight='bold')\n",
47
+ " plt.ylabel('Asset Type', fontweight='bold')\n",
48
+ "\n",
49
+ " ax = plt.gca()\n",
50
+ "\n",
51
+ " # Hide all axis spines\n",
52
+ " for spine in ax.spines.values():\n",
53
+ " spine.set_visible(False)\n",
54
+ "\n",
55
+ " # Keep ticks visible\n",
56
+ " ax.xaxis.set_ticks_position('bottom')\n",
57
+ " ax.yaxis.set_ticks_position('left')\n",
58
+ "\n",
59
+ " # Bold tick labels\n",
60
+ " for label in ax.get_xticklabels() + ax.get_yticklabels():\n",
61
+ " label.set_fontweight('bold')\n",
62
+ "\n",
63
+ " # Format x-axis ticks: 25000 → 25 k\n",
64
+ " ax.xaxis.set_major_formatter(FuncFormatter(lambda x, _: f'{int(x/1000)} k' if x >= 1000 else f'{int(x)}'))\n",
65
+ "\n",
66
+ " # Add percentage labels to the bars\n",
67
+ " for bar, percentage in zip(bars, type_counts['Percentage']):\n",
68
+ " plt.text(bar.get_width() + 5, bar.get_y() + bar.get_height()/2,\n",
69
+ " f' {percentage}%', va='center', color='blueviolet', fontweight='bold')\n",
70
+ "\n",
71
+ " plt.tight_layout()\n",
72
+ " plt.savefig(out_file, format='svg')\n",
73
+ " plt.show()\n"
74
+ ]
75
+ }
76
+ ],
77
+ "metadata": {
78
+ "language_info": {
79
+ "name": "python"
80
+ }
81
+ },
82
+ "nbformat": 4,
83
+ "nbformat_minor": 5
84
+ }
plots/Figure_12.svg ADDED