{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5c1cbcaf",
   "metadata": {},
   "source": [
    "# Greenhouse gas calculations\n",
    "This notebook shows an advanced `calc_ghg(...)` workflow in MARIO. It starts by inspecting the built-in GHG profile registry, shows how to check which gases are covered for each supported database profile, and then compares harmonized GHG results across EXIOBASE, EORA26, and ADB.\n",
    "\n",
    "For built-in profiles, `calc_ghg(...)` also accepts `time_horizon` and `ipcc_report` to resolve profile-specific GWP values when multiple IPCC variants are available.\n",
    "\n",
    "The workflow is organized in four steps:\n",
    "\n",
    "- inspect the preconfigured `calc_ghg` profiles and verify which gases are covered by the profiles used in this comparison\n",
    "- compute regional `PBA` and `CBA` totals for the three databases\n",
    "- harmonize units and conclude with a cross-database chart for selected countries\n",
    "\n",
    "> **Note (beta):** This workflow uses a beta GHG aggregation method. It will be updated soon to support additional `time_horizon` options and broader satellite coverage across all environmentally extended databases currently supported by MARIO parsing."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8b4963d",
   "metadata": {},
   "source": [
    "## 1. Inspect built-in `calc_ghg` profiles\n",
    "\n",
    "`Database.calc_ghg(...)` can use a built-in profile or a profile passed explicitly with `profile=`. \n",
    "The available profiles currently are `exiobase_monetary`, `exiobase_hybrid`, `eora`, `adb`, `gloria`, `emerging`.\n",
    "\n",
    "In the built-in registry, some gases are stored as scalar factors and some as nested mappings. In practice, `CO2` and total `GHG` remain scalar (`1`), while `CH4` and `N2O` can expose a structure like `{time_horizon: {ipcc_report: factor}}`.\n",
    "\n",
    "This means that `time_horizon` and `ipcc_report` are only relevant when `calc_ghg(...)` uses a built-in `profile`. If you pass a custom flat `gwp={...}` mapping, the behavior stays unchanged."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bdb211c4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'match': ('exiobase', 'monetary'),\n",
       " 'unit': 'kg CO2eq',\n",
       " 'gwp': {'CO2 - combustion - air': 1,\n",
       "  'CH4 - combustion - air': {100: {'AR6': 29.8, 'AR5': 30, 'AR4': 25}},\n",
       "  'N2O - combustion - air': {100: {'AR6': 273, 'AR5': 265, 'AR4': 298}}}}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import mario\n",
    "profile = 'exiobase_monetary'\n",
    "\n",
    "mario.ops.ghg.GHG_PROFILES[profile]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "462d0f13",
   "metadata": {},
   "source": [
    "## 2. Configure the comparison inputs\n",
    "\n",
    "The next cell defines the three databases used in the comparison and the helper functions that keep the workflow aligned across sources.\n",
    "\n",
    "Before running it, update `shared_folder` so it points to your local folder with the database files used in this workflow.\n",
    "\n",
    "In particular, it does three things:\n",
    "\n",
    "- defines the file locations, versions, and years to import\n",
    "- reshapes each database into a common `PBA` and `CBA` output layout\n",
    "- reconciles source-specific region labels to ISO3 codes with the packaged country coverage workbook"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fec4f2c4",
   "metadata": {},
   "source": [
    "### Expected `shared_folder` layout\n",
    "\n",
    "Set `shared_folder` to the root directory that contains the three databases in the folder structure expected by the paths defined in `properties`.\n",
    "\n",
    "```text\n",
    "YOUR_PATH_TO_INPUT_OUTPUT_DATABASES/\n",
    "├── EXIOBASE/\n",
    "│   └── 3.10.2/\n",
    "│       ├── IOT_2010_ixi.zip\n",
    "│       ├── IOT_2015_ixi.zip\n",
    "│       ├── IOT_2018_ixi.zip\n",
    "│       └── IOT_2021_ixi.zip\n",
    "├── EORA/\n",
    "│   └── EORA1/\n",
    "│       └── Eora26/\n",
    "│           ├── Eora26_2010_bp\n",
    "│           └── Eora26_2015_bp\n",
    "└── ADB/\n",
    "    ├── 62 economies/\n",
    "        ├── ADB-MRIO62-2018_September 2024.xlsx\n",
    "        ├── ADB-MRIO62-2021_August 2024.xlsx\n",
    "        ├── ADB-MRIO62-2022_July 2025.xlsx\n",
    "    └── Air emissions/\n",
    "        ├── 2018 EE-MRIOT (Air Emissions).xlsx\n",
    "        ├── 2021 EE-MRIOT (Air Emissions).xlsx\n",
    "        └── 2023 EE-MRIOT (Air Emissions).xlsx\n",
    "```\n",
    "\n",
    "### Notes\n",
    "\n",
    "- Replace `YOUR_PATH_TO_INPUT_OUTPUT_DATABASES` with the local parent folder that contains `EXIOBASE`, `EORA`, and `ADB`.\n",
    "- `{version}`, `{table}`, and `{year}` are filled automatically from the `properties` dictionary.\n",
    "- Folder and file names should match exactly, including spaces in `Air emissions` and in the ADB workbook names."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4f943121",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "mario.set_log_verbosity('critical')\n",
    "from mario.clusters.coverage import load_concordance\n",
    "\n",
    "ghgs = pd.DataFrame()\n",
    "\n",
    "shared_folder = 'YOUR_PATH_TO_INPUT_OUTPUT_DATABASES'\n",
    "properties = {\n",
    "    'exiobase_monetary': {\n",
    "        'path': f'{shared_folder}/EXIOBASE/{{version}}/{{table}}_{{year}}_ixi.zip',\n",
    "        'name': 'EXIOBASE', 'table': 'IOT', 'versions': ['3.10.2'], 'years': [2010,2015,2018,2021],\n",
    "    },\n",
    "    'eora': {\n",
    "        'path': f'{shared_folder}/EORA/EORA1/Eora26/Eora26_{{year}}_bp',\n",
    "        'name': 'EORA26','table': 'IOT','versions': ['199.82'],'years': [2010,2015],\n",
    "    },\n",
    "    'adb': {\n",
    "        'path': f'{shared_folder}/ADB/{{version}}',\n",
    "        'path_satellites': f'{shared_folder}/ADB/Air emissions/{{year}} EE-MRIOT (Air Emissions).xlsx',\n",
    "        'name': 'ADB','table': 'IOT','versions': ['62 economies'],'years': [2018,2021,2023],\n",
    "    },\n",
    "}\n",
    "\n",
    "CONCORDANCE = load_concordance()\n",
    "SOURCE_CONCORDANCE_HINTS = {\n",
    "    'adb': 'ADB',\n",
    "    'eora': 'EORA1',\n",
    "    'exiobase': 'EXIOBASE',\n",
    "}\n",
    "ISO3_VALUES = {\n",
    "    str(value).strip().upper() for value in CONCORDANCE['ISO3'].dropna()\n",
    "}\n",
    "\n",
    "def ghg_rearrangement(db, name, version, table, year):\n",
    "        df_pba = db.E.loc[\"GHG\", :].T.groupby(level=0).sum() + db.EY.loc[\"GHG\", :].T.groupby(level=0).sum()\n",
    "        df_cba = db.F.loc[\"GHG\", :].T.groupby(level=0).sum() + db.EY.loc[\"GHG\", :].T.groupby(level=0).sum()\n",
    "        df_pba = df_pba.to_frame()\n",
    "        df_cba = df_cba.to_frame()\n",
    "        unit = db.units['Satellite account'].loc['GHG','unit']\n",
    "        df_pba.columns = pd.MultiIndex.from_tuples([(name, version, table, year, \"PBA\", unit)], names=['database', 'version', 'table', 'year', 'accounting', 'unit'])\n",
    "        df_cba.columns = pd.MultiIndex.from_tuples([(name, version, table, year, \"CBA\", unit)], names=['database', 'version', 'table', 'year', 'accounting', 'unit'])\n",
    "        df = pd.concat([df_pba, df_cba], axis=1)\n",
    "        return df\n",
    "\n",
    "def reconcile_to_iso3(df, source):\n",
    "    source_value = str(source).strip()\n",
    "    source_column = next(\n",
    "        (\n",
    "            column\n",
    "            for token, column in SOURCE_CONCORDANCE_HINTS.items()\n",
    "            if token in source_value.casefold()\n",
    "        ),\n",
    "        source_value,\n",
    "    )\n",
    "\n",
    "    if source_column not in CONCORDANCE.columns:\n",
    "        raise KeyError(f\"No concordance column found for source '{source}'\")\n",
    "\n",
    "    lookup = {}\n",
    "    for iso3, source_code in CONCORDANCE[['ISO3', source_column]].dropna().itertuples(index=False):\n",
    "        lookup.setdefault(str(source_code).strip().casefold(), str(iso3).strip().upper())\n",
    "\n",
    "    iso3_index = []\n",
    "    for label in df.index:\n",
    "        label_text = str(label).strip()\n",
    "        iso3 = lookup.get(label_text.casefold())\n",
    "        if iso3 is None and label_text.upper() in ISO3_VALUES:\n",
    "            iso3 = label_text.upper()\n",
    "        iso3_index.append(iso3 if iso3 is not None else label_text)\n",
    "\n",
    "    df = df.copy()\n",
    "    df.index = iso3_index\n",
    "    df.index.name = 'Region'\n",
    "    return df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0ed52dd8",
   "metadata": {},
   "source": [
    "## 3. Parse EXIOBASE and compute GHG\n",
    "\n",
    "`EXIOBASE` has a dedicated `exiobase_monetary` profile. The loop below parses each selected year, computes the aggregate GHG row with `calc_ghg(profile='exiobase_monetary', time_horizon=100, ipcc_report='AR6')`, and stores harmonized regional totals in the comparison table.\n",
    "\n",
    "For this profile, `time_horizon` and `ipcc_report` affect the built-in `CH4` and `N2O` factors, while `CO2` remains equal to `1`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "efeae727",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== EXIOBASE 3.10.2 IOT ixi 2010 ===\n",
      "=== EXIOBASE 3.10.2 IOT ixi 2015 ===\n",
      "=== EXIOBASE 3.10.2 IOT ixi 2018 ===\n",
      "=== EXIOBASE 3.10.2 IOT ixi 2021 ===\n"
     ]
    }
   ],
   "source": [
    "p = properties['exiobase_monetary']\n",
    "name, table, path = p['name'], p['table'], p['path']\n",
    "\n",
    "for version in p['versions']:\n",
    "    for year in p['years']:\n",
    "        print(f'=== {name} {version} {table} ixi {year} ===')\n",
    "\n",
    "        db = mario.parse_exiobase(\n",
    "            path=path.format(version=version, year=year, table=table),\n",
    "            table=table,\n",
    "            unit='Monetary',\n",
    "        )\n",
    "\n",
    "        db.calc_ghg(profile='exiobase_monetary', time_horizon=100, ipcc_report='AR6')\n",
    "        ghgs_df = ghg_rearrangement(db, name, version, table, year)\n",
    "        ghgs_df = reconcile_to_iso3(ghgs_df, name)\n",
    "        ghgs = pd.concat([ghgs, ghgs_df], axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4203496a",
   "metadata": {},
   "source": [
    "## 4. Parse EORA26 and compute GHG\n",
    "\n",
    "`EORA26` uses a broader profile with many sub-source rows. The same pattern applies here: parse the database, run `calc_ghg(profile='eora', time_horizon=100, ipcc_report='AR6')`, reconcile regions to ISO3, and append the result to the common comparison table."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "59dacc70",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== EORA26 199.82 IOT ixi 2010 ===\n",
      "=== EORA26 199.82 IOT ixi 2015 ===\n"
     ]
    }
   ],
   "source": [
    "p = properties['eora']\n",
    "name, table, path = p['name'], p['table'], p['path']\n",
    "\n",
    "for version in p['versions']:\n",
    "    for year in p['years']:\n",
    "        print(f'=== {name} {version} {table} ixi {year} ===')\n",
    "\n",
    "        db = mario.parse_eora(\n",
    "            path=path.format(year=year),\n",
    "            multi_region=True,\n",
    "        )\n",
    "\n",
    "        db.calc_ghg(profile='eora', time_horizon=100, ipcc_report='AR6')\n",
    "        ghgs_df = ghg_rearrangement(db, name, version, table, year)\n",
    "        ghgs_df = reconcile_to_iso3(ghgs_df, name)\n",
    "        ghgs = pd.concat([ghgs, ghgs_df], axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "40747cab",
   "metadata": {},
   "source": [
    "## 5. Parse ADB and compute GHG\n",
    "\n",
    "`ADB` already exposes a total GHG extension profile. After parsing the database and satellite workbook, the loop below computes `GHG`, harmonizes region labels, and appends the result to the same table used for EXIOBASE and EORA.\n",
    "\n",
    "Here `time_horizon` and `ipcc_report` are not needed in practice, because the built-in profile already points to a total `GHG` row with scalar factor `1`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "44fb86fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "=== ADB 62 economies IOT ixi 2018 ===\n",
      "=== ADB 62 economies IOT ixi 2021 ===\n",
      "=== ADB 62 economies IOT ixi 2023 ===\n"
     ]
    }
   ],
   "source": [
    "p = properties['adb']\n",
    "name, table, path = p['name'], p['table'], p['path']\n",
    "\n",
    "for version in p['versions']:\n",
    "    for year in p['years']:\n",
    "        print(f'=== {name} {version} {table} ixi {year} ===')\n",
    "\n",
    "        db = mario.parse_adb(\n",
    "            path=path.format(version=version),\n",
    "            year=year,\n",
    "            add_extensions=p['path_satellites'].format(year=year),\n",
    "        )\n",
    "\n",
    "        db.calc_ghg(profile='adb')\n",
    "        ghgs_df = ghg_rearrangement(db, name, version, table, year)\n",
    "        ghgs_df = reconcile_to_iso3(ghgs_df, name)\n",
    "        ghgs = pd.concat([ghgs, ghgs_df], axis=1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e08aec58",
   "metadata": {},
   "source": [
    "## 6. Spot-check one harmonized country\n",
    "\n",
    "Before reshaping and plotting, it is useful to inspect one row after all three databases have been appended. The cell below checks the full `USA` record after profile application and ISO3 reconciliation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "977d25fe",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "database  version       table  year  accounting  unit                                               \n",
       "EXIOBASE  3.10.2        IOT    2010  PBA         kg                                                     5.513016e+12\n",
       "                                     CBA         kg                                                     5.979904e+12\n",
       "                               2015  PBA         kg                                                     5.086859e+12\n",
       "                                     CBA         kg                                                     5.382269e+12\n",
       "                               2018  PBA         kg                                                     5.076462e+12\n",
       "                                     CBA         kg                                                     5.406201e+12\n",
       "                               2021  PBA         kg                                                     4.662891e+12\n",
       "                                     CBA         kg                                                     5.250987e+12\n",
       "EORA26    199.82        IOT    2010  PBA         Gg                                                     7.591209e+06\n",
       "                                     CBA         Gg                                                     8.594610e+06\n",
       "                               2015  PBA         Gg                                                     7.591209e+06\n",
       "                                     CBA         Gg                                                     8.327947e+06\n",
       "ADB       62 economies  IOT    2018  PBA         Gigagrams of Carbon Dioxide equivalent (Gg of CO2e)    6.290197e+06\n",
       "                                     CBA         Gigagrams of Carbon Dioxide equivalent (Gg of CO2e)    6.608713e+06\n",
       "                               2021  PBA         Gigagrams of Carbon Dioxide equivalent (Gg of CO2e)    6.022567e+06\n",
       "                                     CBA         Gigagrams of Carbon Dioxide equivalent (Gg of CO2e)    6.509001e+06\n",
       "                               2023  PBA         Gigagrams of Carbon Dioxide equivalent (Gg of CO2e)    5.968822e+06\n",
       "                                     CBA         Gigagrams of Carbon Dioxide equivalent (Gg of CO2e)    6.364799e+06\n",
       "Name: USA, dtype: float64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ghgs.loc['USA',:]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f78c0ceb",
   "metadata": {},
   "source": [
    "## 7. Harmonize units and prepare a tidy table\n",
    "\n",
    "`calc_ghg` preserves the native unit of each profile, so the three sources are not directly comparable yet. The next cell reshapes the aggregated output to long format and converts everything to `Mt CO2`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "0c860c02",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>database</th>\n",
       "      <th>version</th>\n",
       "      <th>table</th>\n",
       "      <th>year</th>\n",
       "      <th>accounting</th>\n",
       "      <th>unit</th>\n",
       "      <th>Region</th>\n",
       "      <th>value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>EXIOBASE</td>\n",
       "      <td>3.10.2</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2010</td>\n",
       "      <td>PBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>AUT</td>\n",
       "      <td>67.120733</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>EXIOBASE</td>\n",
       "      <td>3.10.2</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2010</td>\n",
       "      <td>PBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>AUS</td>\n",
       "      <td>406.737233</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>EXIOBASE</td>\n",
       "      <td>3.10.2</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2010</td>\n",
       "      <td>PBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>BEL</td>\n",
       "      <td>108.324240</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>EXIOBASE</td>\n",
       "      <td>3.10.2</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2010</td>\n",
       "      <td>PBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>BGR</td>\n",
       "      <td>43.529051</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>EXIOBASE</td>\n",
       "      <td>3.10.2</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2010</td>\n",
       "      <td>PBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>BRA</td>\n",
       "      <td>407.413978</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3505</th>\n",
       "      <td>ADB</td>\n",
       "      <td>62 economies</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2023</td>\n",
       "      <td>CBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>WSM</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3506</th>\n",
       "      <td>ADB</td>\n",
       "      <td>62 economies</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2023</td>\n",
       "      <td>CBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>YEM</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3507</th>\n",
       "      <td>ADB</td>\n",
       "      <td>62 economies</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2023</td>\n",
       "      <td>CBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>ZMB</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3508</th>\n",
       "      <td>ADB</td>\n",
       "      <td>62 economies</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2023</td>\n",
       "      <td>CBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>ZWE</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3509</th>\n",
       "      <td>ADB</td>\n",
       "      <td>62 economies</td>\n",
       "      <td>IOT</td>\n",
       "      <td>2023</td>\n",
       "      <td>CBA</td>\n",
       "      <td>Mt CO2</td>\n",
       "      <td>RoW</td>\n",
       "      <td>6672.575371</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3510 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      database       version table  year accounting    unit Region  \\\n",
       "0     EXIOBASE        3.10.2   IOT  2010        PBA  Mt CO2    AUT   \n",
       "1     EXIOBASE        3.10.2   IOT  2010        PBA  Mt CO2    AUS   \n",
       "2     EXIOBASE        3.10.2   IOT  2010        PBA  Mt CO2    BEL   \n",
       "3     EXIOBASE        3.10.2   IOT  2010        PBA  Mt CO2    BGR   \n",
       "4     EXIOBASE        3.10.2   IOT  2010        PBA  Mt CO2    BRA   \n",
       "...        ...           ...   ...   ...        ...     ...    ...   \n",
       "3505       ADB  62 economies   IOT  2023        CBA  Mt CO2    WSM   \n",
       "3506       ADB  62 economies   IOT  2023        CBA  Mt CO2    YEM   \n",
       "3507       ADB  62 economies   IOT  2023        CBA  Mt CO2    ZMB   \n",
       "3508       ADB  62 economies   IOT  2023        CBA  Mt CO2    ZWE   \n",
       "3509       ADB  62 economies   IOT  2023        CBA  Mt CO2    RoW   \n",
       "\n",
       "            value  \n",
       "0       67.120733  \n",
       "1      406.737233  \n",
       "2      108.324240  \n",
       "3       43.529051  \n",
       "4      407.413978  \n",
       "...           ...  \n",
       "3505          NaN  \n",
       "3506          NaN  \n",
       "3507          NaN  \n",
       "3508          NaN  \n",
       "3509  6672.575371  \n",
       "\n",
       "[3510 rows x 8 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = ghgs.unstack().to_frame()\n",
    "df.columns = ['value']\n",
    "df.reset_index(inplace=True)\n",
    "\n",
    "factors = pd.Series(index=df.index, dtype=float)\n",
    "\n",
    "factors[df['unit'].eq('kg')] = 1e-9\n",
    "factors[df['unit'].str.contains('Gg', na=False)] = 1e-3\n",
    "\n",
    "if factors.isna().any():\n",
    "    raise ValueError(f\"Unsupported units found: {df.loc[factors.isna(), 'unit'].unique().tolist()}\")\n",
    "\n",
    "df = df.copy()\n",
    "df['value'] = df['value'] * factors\n",
    "df['unit'] = 'Mt CO2'\n",
    "\n",
    "df\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f953f089",
   "metadata": {},
   "source": [
    "## 8. Compare the three databases visually\n",
    "\n",
    "The final chart keeps `PBA` and `CBA` side by side and facets by country. This makes it easier to compare both the scale of emissions and the accounting convention differences across EXIOBASE, EORA26, and ADB."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4924e226",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "plotlyServerURL": "https://plot.ly"
       },
       "data": [
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=ITA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, CBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "ADB | 62 economies, CBA",
         "offsetgroup": "ADB | 62 economies, CBA",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x5",
         "y": {
          "bdata": "DU9263ZtgUCUqS3vnWaAQOjH+hwGhH5A",
          "dtype": "f8"
         },
         "yaxis": "y5"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=ITA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, PBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "ADB | 62 economies, PBA",
         "offsetgroup": "ADB | 62 economies, PBA",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x5",
         "y": {
          "bdata": "piL7zSNBe0AMOJjAbiN6QBmYd3h0RHhA",
          "dtype": "f8"
         },
         "yaxis": "y5"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=ITA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, CBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EORA26 | 199.82, CBA",
         "offsetgroup": "EORA26 | 199.82, CBA",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x5",
         "y": {
          "bdata": "Z/T/2WWfj0BvGySMnzuNQA==",
          "dtype": "f8"
         },
         "yaxis": "y5"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=ITA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, PBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EORA26 | 199.82, PBA",
         "offsetgroup": "EORA26 | 199.82, PBA",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x5",
         "y": {
          "bdata": "VaN1v2W6g0BVo3W/ZbqDQA==",
          "dtype": "f8"
         },
         "yaxis": "y5"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=ITA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, CBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EXIOBASE | 3.10.2, CBA",
         "offsetgroup": "EXIOBASE | 3.10.2, CBA",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x5",
         "y": {
          "bdata": "NxZ2QabbgEDlucuS5FR5QIbGxMRvlHhAfOEEWo02eUA=",
          "dtype": "f8"
         },
         "yaxis": "y5"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=ITA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, PBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EXIOBASE | 3.10.2, PBA",
         "offsetgroup": "EXIOBASE | 3.10.2, PBA",
         "orientation": "v",
         "showlegend": true,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x5",
         "y": {
          "bdata": "yzTtBEE9eUACH+V8Tvh0QNV28OBTCXRA6JfS9O0wc0A=",
          "dtype": "f8"
         },
         "yaxis": "y5"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=DEU<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, CBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "ADB | 62 economies, CBA",
         "offsetgroup": "ADB | 62 economies, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x6",
         "y": {
          "bdata": "Ws0oU+oSkUAfaC6mZHuOQIWlvOIT84pA",
          "dtype": "f8"
         },
         "yaxis": "y6"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=DEU<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, PBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "ADB | 62 economies, PBA",
         "offsetgroup": "ADB | 62 economies, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x6",
         "y": {
          "bdata": "fT3XALsWjUATQ0Zf5QmKQJnq2c8YKIdA",
          "dtype": "f8"
         },
         "yaxis": "y6"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=DEU<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, CBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EORA26 | 199.82, CBA",
         "offsetgroup": "EORA26 | 199.82, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x6",
         "y": {
          "bdata": "BeahEONFmEAqZ72qcSuYQA==",
          "dtype": "f8"
         },
         "yaxis": "y6"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=DEU<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, PBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EORA26 | 199.82, PBA",
         "offsetgroup": "EORA26 | 199.82, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x6",
         "y": {
          "bdata": "e9GGgn6fkUB70YaCfp+RQA==",
          "dtype": "f8"
         },
         "yaxis": "y6"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=DEU<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, CBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EXIOBASE | 3.10.2, CBA",
         "offsetgroup": "EXIOBASE | 3.10.2, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x6",
         "y": {
          "bdata": "HoQ30IqKi0DjDUN9qR2KQHXGATUouIhAuZUDPkOhhkA=",
          "dtype": "f8"
         },
         "yaxis": "y6"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=DEU<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, PBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EXIOBASE | 3.10.2, PBA",
         "offsetgroup": "EXIOBASE | 3.10.2, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x6",
         "y": {
          "bdata": "bRx6ynzdi0DOnj8LRdOJQCwddnAfI4hAFNM7JH8VhUA=",
          "dtype": "f8"
         },
         "yaxis": "y6"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=FRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, CBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "ADB | 62 economies, CBA",
         "offsetgroup": "ADB | 62 economies, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x7",
         "y": {
          "bdata": "ra/kB4bBgkBrbH45VjqBQHMph7EadX9A",
          "dtype": "f8"
         },
         "yaxis": "y7"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=FRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, PBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "ADB | 62 economies, PBA",
         "offsetgroup": "ADB | 62 economies, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x7",
         "y": {
          "bdata": "dr+PZypcfkBwUCX0z418QEFuEItqAHpA",
          "dtype": "f8"
         },
         "yaxis": "y7"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=FRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, CBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EORA26 | 199.82, CBA",
         "offsetgroup": "EORA26 | 199.82, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x7",
         "y": {
          "bdata": "8w8X+JOdjkAK7cJlLlaNQA==",
          "dtype": "f8"
         },
         "yaxis": "y7"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=FRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, PBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EORA26 | 199.82, PBA",
         "offsetgroup": "EORA26 | 199.82, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x7",
         "y": {
          "bdata": "ObwdRa8ThUA5vB1FrxOFQA==",
          "dtype": "f8"
         },
         "yaxis": "y7"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=FRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, CBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EXIOBASE | 3.10.2, CBA",
         "offsetgroup": "EXIOBASE | 3.10.2, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x7",
         "y": {
          "bdata": "L4lcH7OqfEAHwtmE4Ol4QDRgDRagjHdA3+LvRj3WeEA=",
          "dtype": "f8"
         },
         "yaxis": "y7"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=FRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, PBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EXIOBASE | 3.10.2, PBA",
         "offsetgroup": "EXIOBASE | 3.10.2, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x7",
         "y": {
          "bdata": "NgL+sYI5dkDe1UqZ6zB0QJBm3BYEQXRAh6vxpTEvc0A=",
          "dtype": "f8"
         },
         "yaxis": "y7"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=CHN<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, CBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "ADB | 62 economies, CBA",
         "offsetgroup": "ADB | 62 economies, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x8",
         "y": {
          "bdata": "DBz5uqNxy0CCYDf6eabNQODBlbz5yc5A",
          "dtype": "f8"
         },
         "yaxis": "y8"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=CHN<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, PBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "ADB | 62 economies, PBA",
         "offsetgroup": "ADB | 62 economies, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x8",
         "y": {
          "bdata": "f0YPpx1sy0AdMdLvsrLNQJMGfWmwOs9A",
          "dtype": "f8"
         },
         "yaxis": "y8"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=CHN<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, CBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EORA26 | 199.82, CBA",
         "offsetgroup": "EORA26 | 199.82, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x8",
         "y": {
          "bdata": "SOZr2hlPx0CL3uFWE9zHQA==",
          "dtype": "f8"
         },
         "yaxis": "y8"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=CHN<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, PBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EORA26 | 199.82, PBA",
         "offsetgroup": "EORA26 | 199.82, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x8",
         "y": {
          "bdata": "5mXyzV9EyEDmZfLNX0TIQA==",
          "dtype": "f8"
         },
         "yaxis": "y8"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=CHN<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, CBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EXIOBASE | 3.10.2, CBA",
         "offsetgroup": "EXIOBASE | 3.10.2, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x8",
         "y": {
          "bdata": "AtfWOc5TvUA3SlgsaBnBQKel0d4SP8JArZy4/XhRxEA=",
          "dtype": "f8"
         },
         "yaxis": "y8"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=CHN<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, PBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EXIOBASE | 3.10.2, PBA",
         "offsetgroup": "EXIOBASE | 3.10.2, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x8",
         "y": {
          "bdata": "FlC2GOVWv0BeXOQf7UrCQD+Kw3xUk8NAqE4Mz0YcxUA=",
          "dtype": "f8"
         },
         "yaxis": "y8"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=USA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, CBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "ADB | 62 economies, CBA",
         "offsetgroup": "ADB | 62 economies, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x",
         "y": {
          "bdata": "f+a0arbQuUCKLVRgAG25QIelN5DM3LhA",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=USA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, PBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "ADB | 62 economies, PBA",
         "offsetgroup": "ADB | 62 economies, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x",
         "y": {
          "bdata": "OcqCaDKSuECibOsfkYa3QMf4jVbSULdA",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=USA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, CBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EORA26 | 199.82, CBA",
         "offsetgroup": "EORA26 | 199.82, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x",
         "y": {
          "bdata": "vdoMDE7JwEAcfnAr+UPAQA==",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=USA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, PBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EORA26 | 199.82, PBA",
         "offsetgroup": "EORA26 | 199.82, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x",
         "y": {
          "bdata": "LQhnnjWnvUAtCGeeNae9QA==",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=USA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, CBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EXIOBASE | 3.10.2, CBA",
         "offsetgroup": "EXIOBASE | 3.10.2, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x",
         "y": {
          "bdata": "ZlyMhOdbt0Amq5byRAa1QBCe4mIzHrVAKRs7jvyCtEA=",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=USA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, PBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EXIOBASE | 3.10.2, PBA",
         "offsetgroup": "EXIOBASE | 3.10.2, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x",
         "y": {
          "bdata": "fcPv/wOJtUDleLnp296zQJjWYk121LNAkqUAF+Q2skA=",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=BRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, CBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "ADB | 62 economies, CBA",
         "offsetgroup": "ADB | 62 economies, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x2",
         "y": {
          "bdata": "NRREfcGJkEA2Rv2+AQWSQAfJxk5FtZFA",
          "dtype": "f8"
         },
         "yaxis": "y2"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=BRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, PBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "ADB | 62 economies, PBA",
         "offsetgroup": "ADB | 62 economies, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x2",
         "y": {
          "bdata": "SNM0k3ARk0DflSAS/UGUQC67U9orZZRA",
          "dtype": "f8"
         },
         "yaxis": "y2"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=BRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, CBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EORA26 | 199.82, CBA",
         "offsetgroup": "EORA26 | 199.82, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x2",
         "y": {
          "bdata": "AD2VtS6VnUCHbbaNzmedQA==",
          "dtype": "f8"
         },
         "yaxis": "y2"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=BRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, PBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EORA26 | 199.82, PBA",
         "offsetgroup": "EORA26 | 199.82, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x2",
         "y": {
          "bdata": "3G7GwM3Cm0DcbsbAzcKbQA==",
          "dtype": "f8"
         },
         "yaxis": "y2"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=BRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, CBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EXIOBASE | 3.10.2, CBA",
         "offsetgroup": "EXIOBASE | 3.10.2, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x2",
         "y": {
          "bdata": "GCYm3at5fUCXGdTcGgGAQAWC/CkHeX5Arkita5qsfkA=",
          "dtype": "f8"
         },
         "yaxis": "y2"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=BRA<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, PBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EXIOBASE | 3.10.2, PBA",
         "offsetgroup": "EXIOBASE | 3.10.2, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x2",
         "y": {
          "bdata": "kcbFp592eUAslkCYg5d+QIdlZSXU4HtAYCKJvYhafUA=",
          "dtype": "f8"
         },
         "yaxis": "y2"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=RUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, CBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "ADB | 62 economies, CBA",
         "offsetgroup": "ADB | 62 economies, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x3",
         "y": {
          "bdata": "6zp9tW24mkBmOd3MkVKcQHW1rA2CZKBA",
          "dtype": "f8"
         },
         "yaxis": "y3"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=RUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, PBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "ADB | 62 economies, PBA",
         "offsetgroup": "ADB | 62 economies, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x3",
         "y": {
          "bdata": "3dPzhmXZokC3s9B3X+qjQBl9Av7W1qRA",
          "dtype": "f8"
         },
         "yaxis": "y3"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=RUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, CBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EORA26 | 199.82, CBA",
         "offsetgroup": "EORA26 | 199.82, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x3",
         "y": {
          "bdata": "/LsoIwLroEDF3wkNePigQA==",
          "dtype": "f8"
         },
         "yaxis": "y3"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=RUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, PBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EORA26 | 199.82, PBA",
         "offsetgroup": "EORA26 | 199.82, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x3",
         "y": {
          "bdata": "jzEvQU6HpkCPMS9BToemQA==",
          "dtype": "f8"
         },
         "yaxis": "y3"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=RUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, CBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EXIOBASE | 3.10.2, CBA",
         "offsetgroup": "EXIOBASE | 3.10.2, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x3",
         "y": {
          "bdata": "qscQLzGQkkBHL2Wz4xSSQB0KdSfGlJNAYp1W/SZTlEA=",
          "dtype": "f8"
         },
         "yaxis": "y3"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=RUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, PBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EXIOBASE | 3.10.2, PBA",
         "offsetgroup": "EXIOBASE | 3.10.2, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x3",
         "y": {
          "bdata": "X0lnaVdsmEA1qg8HyHOYQJrIR+owXZlAuiZe3XFHmkA=",
          "dtype": "f8"
         },
         "yaxis": "y3"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=AUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, CBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": ""
          }
         },
         "name": "ADB | 62 economies, CBA",
         "offsetgroup": "ADB | 62 economies, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x4",
         "y": {
          "bdata": "A6tbBVEEgUD1pvMHaFGAQNOfUOI9tYBA",
          "dtype": "f8"
         },
         "yaxis": "y4"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ],
          [
           "ADB",
           "62 economies",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=ADB | 62 economies<br>Accounting=%{customdata[2]}<br>Region=AUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "ADB | 62 economies, PBA",
         "marker": {
          "color": "#636efa",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "ADB | 62 economies, PBA",
         "offsetgroup": "ADB | 62 economies, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "4gflB+cH",
          "dtype": "i2"
         },
         "xaxis": "x4",
         "y": {
          "bdata": "thIxeMZPg0AL+9ZYOwqCQLXMXO9u6YFA",
          "dtype": "f8"
         },
         "yaxis": "y4"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=AUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, CBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EORA26 | 199.82, CBA",
         "offsetgroup": "EORA26 | 199.82, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x4",
         "y": {
          "bdata": "OFV7RKZSjEB902xjSF2MQA==",
          "dtype": "f8"
         },
         "yaxis": "y4"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ],
          [
           "EORA26",
           "199.82",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EORA26 | 199.82<br>Accounting=%{customdata[2]}<br>Region=AUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EORA26 | 199.82, PBA",
         "marker": {
          "color": "#EF553B",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EORA26 | 199.82, PBA",
         "offsetgroup": "EORA26 | 199.82, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffBw==",
          "dtype": "i2"
         },
         "xaxis": "x4",
         "y": {
          "bdata": "wezBF+WckEDB7MEX5ZyQQA==",
          "dtype": "f8"
         },
         "yaxis": "y4"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "CBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=AUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, CBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": ""
          }
         },
         "name": "EXIOBASE | 3.10.2, CBA",
         "offsetgroup": "EXIOBASE | 3.10.2, CBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x4",
         "y": {
          "bdata": "aBywwNBSekDToUvnZTx5QFsCgSmE2nhAcI/XSjmDeEA=",
          "dtype": "f8"
         },
         "yaxis": "y4"
        },
        {
         "alignmentgroup": "True",
         "customdata": [
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ],
          [
           "EXIOBASE",
           "3.10.2",
           "PBA",
           "Mt CO2"
          ]
         ],
         "hovertemplate": "Database + version=EXIOBASE | 3.10.2<br>Accounting=%{customdata[2]}<br>Region=AUS<br>=%{y}<br>database=%{customdata[0]}<br>version=%{customdata[1]}<br>unit=%{customdata[3]}<extra></extra>",
         "legendgroup": "EXIOBASE | 3.10.2, PBA",
         "marker": {
          "color": "#00cc96",
          "pattern": {
           "shape": "/"
          }
         },
         "name": "EXIOBASE | 3.10.2, PBA",
         "offsetgroup": "EXIOBASE | 3.10.2, PBA",
         "orientation": "v",
         "showlegend": false,
         "textposition": "auto",
         "type": "bar",
         "x": {
          "bdata": "2gffB+IH5Qc=",
          "dtype": "i2"
         },
         "xaxis": "x4",
         "y": {
          "bdata": "7mNqtMtreUAtG5o9Oop4QPZ4XqgUEHlAP6GCilUnd0A=",
          "dtype": "f8"
         },
         "yaxis": "y4"
        }
       ],
       "layout": {
        "annotations": [
         {
          "font": {},
          "showarrow": false,
          "text": "USA",
          "x": 0.1175,
          "xanchor": "center",
          "xref": "paper",
          "y": 0.46499999999999997,
          "yanchor": "bottom",
          "yref": "paper"
         },
         {
          "font": {},
          "showarrow": false,
          "text": "BRA",
          "x": 0.3725,
          "xanchor": "center",
          "xref": "paper",
          "y": 0.46499999999999997,
          "yanchor": "bottom",
          "yref": "paper"
         },
         {
          "font": {},
          "showarrow": false,
          "text": "RUS",
          "x": 0.6275,
          "xanchor": "center",
          "xref": "paper",
          "y": 0.46499999999999997,
          "yanchor": "bottom",
          "yref": "paper"
         },
         {
          "font": {},
          "showarrow": false,
          "text": "AUS",
          "x": 0.8824999999999998,
          "xanchor": "center",
          "xref": "paper",
          "y": 0.46499999999999997,
          "yanchor": "bottom",
          "yref": "paper"
         },
         {
          "font": {},
          "showarrow": false,
          "text": "ITA",
          "x": 0.1175,
          "xanchor": "center",
          "xref": "paper",
          "y": 0.9999999999999999,
          "yanchor": "bottom",
          "yref": "paper"
         },
         {
          "font": {},
          "showarrow": false,
          "text": "DEU",
          "x": 0.3725,
          "xanchor": "center",
          "xref": "paper",
          "y": 0.9999999999999999,
          "yanchor": "bottom",
          "yref": "paper"
         },
         {
          "font": {},
          "showarrow": false,
          "text": "FRA",
          "x": 0.6275,
          "xanchor": "center",
          "xref": "paper",
          "y": 0.9999999999999999,
          "yanchor": "bottom",
          "yref": "paper"
         },
         {
          "font": {},
          "showarrow": false,
          "text": "CHN",
          "x": 0.8824999999999998,
          "xanchor": "center",
          "xref": "paper",
          "y": 0.9999999999999999,
          "yanchor": "bottom",
          "yref": "paper"
         }
        ],
        "barmode": "group",
        "height": 440,
        "legend": {
         "title": {
          "text": "Database + version"
         },
         "tracegroupgap": 0
        },
        "template": {
         "data": {
          "bar": [
           {
            "error_x": {
             "color": "#2a3f5f"
            },
            "error_y": {
             "color": "#2a3f5f"
            },
            "marker": {
             "line": {
              "color": "white",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "bar"
           }
          ],
          "barpolar": [
           {
            "marker": {
             "line": {
              "color": "white",
              "width": 0.5
             },
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "barpolar"
           }
          ],
          "carpet": [
           {
            "aaxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "#C8D4E3",
             "linecolor": "#C8D4E3",
             "minorgridcolor": "#C8D4E3",
             "startlinecolor": "#2a3f5f"
            },
            "baxis": {
             "endlinecolor": "#2a3f5f",
             "gridcolor": "#C8D4E3",
             "linecolor": "#C8D4E3",
             "minorgridcolor": "#C8D4E3",
             "startlinecolor": "#2a3f5f"
            },
            "type": "carpet"
           }
          ],
          "choropleth": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "choropleth"
           }
          ],
          "contour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "histogram2dcontour"
           }
          ],
          "mesh3d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "mesh3d"
           }
          ],
          "parcoords": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "parcoords"
           }
          ],
          "pie": [
           {
            "automargin": true,
            "type": "pie"
           }
          ],
          "scatter": [
           {
            "fillpattern": {
             "fillmode": "overlay",
             "size": 10,
             "solidity": 0.2
            },
            "type": "scatter"
           }
          ],
          "scatter3d": [
           {
            "line": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatter3d"
           }
          ],
          "scattercarpet": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattercarpet"
           }
          ],
          "scattergeo": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergeo"
           }
          ],
          "scattergl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattergl"
           }
          ],
          "scattermap": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermap"
           }
          ],
          "scattermapbox": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scattermapbox"
           }
          ],
          "scatterpolar": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolar"
           }
          ],
          "scatterpolargl": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterpolargl"
           }
          ],
          "scatterternary": [
           {
            "marker": {
             "colorbar": {
              "outlinewidth": 0,
              "ticks": ""
             }
            },
            "type": "scatterternary"
           }
          ],
          "surface": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0,
              "#0d0887"
             ],
             [
              0.1111111111111111,
              "#46039f"
             ],
             [
              0.2222222222222222,
              "#7201a8"
             ],
             [
              0.3333333333333333,
              "#9c179e"
             ],
             [
              0.4444444444444444,
              "#bd3786"
             ],
             [
              0.5555555555555556,
              "#d8576b"
             ],
             [
              0.6666666666666666,
              "#ed7953"
             ],
             [
              0.7777777777777778,
              "#fb9f3a"
             ],
             [
              0.8888888888888888,
              "#fdca26"
             ],
             [
              1,
              "#f0f921"
             ]
            ],
            "type": "surface"
           }
          ],
          "table": [
           {
            "cells": {
             "fill": {
              "color": "#EBF0F8"
             },
             "line": {
              "color": "white"
             }
            },
            "header": {
             "fill": {
              "color": "#C8D4E3"
             },
             "line": {
              "color": "white"
             }
            },
            "type": "table"
           }
          ]
         },
         "layout": {
          "annotationdefaults": {
           "arrowcolor": "#2a3f5f",
           "arrowhead": 0,
           "arrowwidth": 1
          },
          "autotypenumbers": "strict",
          "coloraxis": {
           "colorbar": {
            "outlinewidth": 0,
            "ticks": ""
           }
          },
          "colorscale": {
           "diverging": [
            [
             0,
             "#8e0152"
            ],
            [
             0.1,
             "#c51b7d"
            ],
            [
             0.2,
             "#de77ae"
            ],
            [
             0.3,
             "#f1b6da"
            ],
            [
             0.4,
             "#fde0ef"
            ],
            [
             0.5,
             "#f7f7f7"
            ],
            [
             0.6,
             "#e6f5d0"
            ],
            [
             0.7,
             "#b8e186"
            ],
            [
             0.8,
             "#7fbc41"
            ],
            [
             0.9,
             "#4d9221"
            ],
            [
             1,
             "#276419"
            ]
           ],
           "sequential": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0,
             "#0d0887"
            ],
            [
             0.1111111111111111,
             "#46039f"
            ],
            [
             0.2222222222222222,
             "#7201a8"
            ],
            [
             0.3333333333333333,
             "#9c179e"
            ],
            [
             0.4444444444444444,
             "#bd3786"
            ],
            [
             0.5555555555555556,
             "#d8576b"
            ],
            [
             0.6666666666666666,
             "#ed7953"
            ],
            [
             0.7777777777777778,
             "#fb9f3a"
            ],
            [
             0.8888888888888888,
             "#fdca26"
            ],
            [
             1,
             "#f0f921"
            ]
           ]
          },
          "colorway": [
           "#636efa",
           "#EF553B",
           "#00cc96",
           "#ab63fa",
           "#FFA15A",
           "#19d3f3",
           "#FF6692",
           "#B6E880",
           "#FF97FF",
           "#FECB52"
          ],
          "font": {
           "color": "#2a3f5f"
          },
          "geo": {
           "bgcolor": "white",
           "lakecolor": "white",
           "landcolor": "white",
           "showlakes": true,
           "showland": true,
           "subunitcolor": "#C8D4E3"
          },
          "hoverlabel": {
           "align": "left"
          },
          "hovermode": "closest",
          "mapbox": {
           "style": "light"
          },
          "paper_bgcolor": "white",
          "plot_bgcolor": "white",
          "polar": {
           "angularaxis": {
            "gridcolor": "#EBF0F8",
            "linecolor": "#EBF0F8",
            "ticks": ""
           },
           "bgcolor": "white",
           "radialaxis": {
            "gridcolor": "#EBF0F8",
            "linecolor": "#EBF0F8",
            "ticks": ""
           }
          },
          "scene": {
           "xaxis": {
            "backgroundcolor": "white",
            "gridcolor": "#DFE8F3",
            "gridwidth": 2,
            "linecolor": "#EBF0F8",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "#EBF0F8"
           },
           "yaxis": {
            "backgroundcolor": "white",
            "gridcolor": "#DFE8F3",
            "gridwidth": 2,
            "linecolor": "#EBF0F8",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "#EBF0F8"
           },
           "zaxis": {
            "backgroundcolor": "white",
            "gridcolor": "#DFE8F3",
            "gridwidth": 2,
            "linecolor": "#EBF0F8",
            "showbackground": true,
            "ticks": "",
            "zerolinecolor": "#EBF0F8"
           }
          },
          "shapedefaults": {
           "line": {
            "color": "#2a3f5f"
           }
          },
          "ternary": {
           "aaxis": {
            "gridcolor": "#DFE8F3",
            "linecolor": "#A2B1C6",
            "ticks": ""
           },
           "baxis": {
            "gridcolor": "#DFE8F3",
            "linecolor": "#A2B1C6",
            "ticks": ""
           },
           "bgcolor": "white",
           "caxis": {
            "gridcolor": "#DFE8F3",
            "linecolor": "#A2B1C6",
            "ticks": ""
           }
          },
          "title": {
           "x": 0.05
          },
          "xaxis": {
           "automargin": true,
           "gridcolor": "#EBF0F8",
           "linecolor": "#EBF0F8",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "#EBF0F8",
           "zerolinewidth": 2
          },
          "yaxis": {
           "automargin": true,
           "gridcolor": "#EBF0F8",
           "linecolor": "#EBF0F8",
           "ticks": "",
           "title": {
            "standoff": 15
           },
           "zerolinecolor": "#EBF0F8",
           "zerolinewidth": 2
          }
         }
        },
        "title": {
         "text": "PBA and CBA GHG emissions for selected countries in different MRIO databases (MtonCO2eq)"
        },
        "width": 1400,
        "xaxis": {
         "anchor": "y",
         "categoryarray": [
          2010,
          2015,
          2018,
          2021,
          2023
         ],
         "categoryorder": "array",
         "domain": [
          0,
          0.235
         ],
         "title": {
          "text": ""
         },
         "type": "category"
        },
        "xaxis2": {
         "anchor": "y2",
         "categoryarray": [
          2010,
          2015,
          2018,
          2021,
          2023
         ],
         "categoryorder": "array",
         "domain": [
          0.255,
          0.49
         ],
         "matches": "x",
         "title": {
          "text": ""
         },
         "type": "category"
        },
        "xaxis3": {
         "anchor": "y3",
         "categoryarray": [
          2010,
          2015,
          2018,
          2021,
          2023
         ],
         "categoryorder": "array",
         "domain": [
          0.51,
          0.745
         ],
         "matches": "x",
         "title": {
          "text": ""
         },
         "type": "category"
        },
        "xaxis4": {
         "anchor": "y4",
         "categoryarray": [
          2010,
          2015,
          2018,
          2021,
          2023
         ],
         "categoryorder": "array",
         "domain": [
          0.7649999999999999,
          0.9999999999999999
         ],
         "matches": "x",
         "title": {
          "text": ""
         },
         "type": "category"
        },
        "xaxis5": {
         "anchor": "y5",
         "domain": [
          0,
          0.235
         ],
         "matches": "x",
         "showticklabels": false,
         "type": "category"
        },
        "xaxis6": {
         "anchor": "y6",
         "domain": [
          0.255,
          0.49
         ],
         "matches": "x",
         "showticklabels": false,
         "type": "category"
        },
        "xaxis7": {
         "anchor": "y7",
         "domain": [
          0.51,
          0.745
         ],
         "matches": "x",
         "showticklabels": false,
         "type": "category"
        },
        "xaxis8": {
         "anchor": "y8",
         "domain": [
          0.7649999999999999,
          0.9999999999999999
         ],
         "matches": "x",
         "showticklabels": false,
         "type": "category"
        },
        "yaxis": {
         "anchor": "x",
         "domain": [
          0,
          0.46499999999999997
         ],
         "showticklabels": true,
         "title": {
          "text": ""
         }
        },
        "yaxis2": {
         "anchor": "x2",
         "domain": [
          0,
          0.46499999999999997
         ],
         "showticklabels": true
        },
        "yaxis3": {
         "anchor": "x3",
         "domain": [
          0,
          0.46499999999999997
         ],
         "showticklabels": true
        },
        "yaxis4": {
         "anchor": "x4",
         "domain": [
          0,
          0.46499999999999997
         ],
         "showticklabels": true
        },
        "yaxis5": {
         "anchor": "x5",
         "domain": [
          0.5349999999999999,
          0.9999999999999999
         ],
         "showticklabels": true,
         "title": {
          "text": ""
         }
        },
        "yaxis6": {
         "anchor": "x6",
         "domain": [
          0.5349999999999999,
          0.9999999999999999
         ],
         "showticklabels": true
        },
        "yaxis7": {
         "anchor": "x7",
         "domain": [
          0.5349999999999999,
          0.9999999999999999
         ],
         "showticklabels": true
        },
        "yaxis8": {
         "anchor": "x8",
         "domain": [
          0.5349999999999999,
          0.9999999999999999
         ],
         "showticklabels": true
        }
       }
      }
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "import plotly.express as px\n",
    "\n",
    "plot_df = df.dropna(subset=['value']).copy()\n",
    "plot_df['database_version'] = plot_df['database'].astype(str) + ' | ' + plot_df['version'].astype(str)\n",
    "\n",
    "selected_regions = [\"ITA\", \"DEU\", \"FRA\", \"CHN\", \"USA\", \"BRA\", \"RUS\", \"AUS\"]  # use sorted(plot_df['Region'].dropna().unique()) for all regions\n",
    "available_regions = set(plot_df['Region'].dropna().astype(str))\n",
    "regions = [region for region in selected_regions if region in available_regions]\n",
    "\n",
    "if not regions:\n",
    "    raise ValueError(f\"No data found for selected regions: {selected_regions}\")\n",
    "\n",
    "plot_df = plot_df[plot_df['Region'].isin(regions)].copy()\n",
    "years = sorted(plot_df['year'].dropna().unique())\n",
    "n_cols = min(4, len(regions))\n",
    "n_rows = math.ceil(len(regions) / n_cols)\n",
    "\n",
    "fig = px.bar(\n",
    "    plot_df.sort_values(['Region', 'year', 'database', 'version', 'accounting']),\n",
    "    x='year',\n",
    "    y='value',\n",
    "    color='database_version',\n",
    "    pattern_shape='accounting',\n",
    "    barmode='group',\n",
    "    facet_col='Region',\n",
    "    facet_col_wrap=n_cols,\n",
    "    category_orders={\n",
    "        'Region': regions,\n",
    "        'year': years,\n",
    "        'database_version': sorted(plot_df['database_version'].unique()),\n",
    "    },\n",
    "    hover_data=['database', 'version', 'accounting', 'unit'],\n",
    "    labels={\n",
    "        'year': '',\n",
    "        'value': '',\n",
    "        'database_version': 'Database + version',\n",
    "        'accounting': 'Accounting',\n",
    "    },\n",
    "    title='PBA and CBA GHG emissions for selected countries in different MRIO databases (MtonCO2eq)',\n",
    ")\n",
    "\n",
    "fig.for_each_annotation(lambda a: a.update(text=a.text.split('=')[-1]))\n",
    "fig.update_xaxes(type='category')\n",
    "fig.update_yaxes(matches=None, showticklabels=True)\n",
    "fig.update_layout(\n",
    "    template='plotly_white',\n",
    "    width=1400,\n",
    "    height=max(400, 220 * n_rows),\n",
    "    legend_title_text='Database + version',\n",
    ")\n",
    "\n",
    "html_path = 'ghg_clustered_by_region.html'\n",
    "fig.write_html(html_path)\n",
    "fig.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "mario",
   "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.13.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
