{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cell-title",
   "metadata": {},
   "source": [
    "# Análisis Ideológico Global e Índice ISID 2026\n",
    "\n",
    "Este cuaderno reproduce los cálculos del **Índice Sintético de Orientación de Derechas (ISID)**, verifica las correlaciones entre los seis ejes ideológicos y exporta gráficos interactivos HTML en la carpeta `../charts/`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "cell-imports",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-22T12:44:50.143575Z",
     "iopub.status.busy": "2026-11-22T12:44:50.143443Z",
     "iopub.status.idle": "2026-11-22T12:44:50.779881Z",
     "shell.execute_reply": "2026-11-22T12:44:50.779253Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Países cargados: 34\n"
     ]
    },
    {
     "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>country_en</th>\n",
       "      <th>pais</th>\n",
       "      <th>region</th>\n",
       "      <th>heritage_2026</th>\n",
       "      <th>fraser_2026</th>\n",
       "      <th>fraser_tamano_estado</th>\n",
       "      <th>hofstede_idv_2023</th>\n",
       "      <th>giem_wvs</th>\n",
       "      <th>gallup_ley_orden_2025</th>\n",
       "      <th>eiu_democracia_2025</th>\n",
       "      <th>...</th>\n",
       "      <th>eje_cultural_iw</th>\n",
       "      <th>pilar1_libre_mercado</th>\n",
       "      <th>pilar2_resp_individual</th>\n",
       "      <th>pilar3_ley_orden</th>\n",
       "      <th>isid_base</th>\n",
       "      <th>isid_mercado</th>\n",
       "      <th>isid_ley_orden</th>\n",
       "      <th>isid_giem</th>\n",
       "      <th>cumple_filtro_antiestatista</th>\n",
       "      <th>ranking_isid_filtrado</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Switzerland</td>\n",
       "      <td>Suiza</td>\n",
       "      <td>Europa</td>\n",
       "      <td>83.7</td>\n",
       "      <td>8.45</td>\n",
       "      <td>7.67</td>\n",
       "      <td>79.0</td>\n",
       "      <td>0.573</td>\n",
       "      <td>91</td>\n",
       "      <td>9.32</td>\n",
       "      <td>...</td>\n",
       "      <td>Secular-Racional | Autoexpresión</td>\n",
       "      <td>81.88</td>\n",
       "      <td>77.85</td>\n",
       "      <td>91.0</td>\n",
       "      <td>83.58</td>\n",
       "      <td>82.49</td>\n",
       "      <td>86.09</td>\n",
       "      <td>81.20</td>\n",
       "      <td>True</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Singapore</td>\n",
       "      <td>Singapur</td>\n",
       "      <td>Asia-Pacífico</td>\n",
       "      <td>84.4</td>\n",
       "      <td>8.43</td>\n",
       "      <td>7.38</td>\n",
       "      <td>43.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>95</td>\n",
       "      <td>6.18</td>\n",
       "      <td>...</td>\n",
       "      <td>Confuciano | Restricción/Orden</td>\n",
       "      <td>81.18</td>\n",
       "      <td>58.40</td>\n",
       "      <td>95.0</td>\n",
       "      <td>78.19</td>\n",
       "      <td>77.11</td>\n",
       "      <td>84.23</td>\n",
       "      <td>NaN</td>\n",
       "      <td>True</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>United States</td>\n",
       "      <td>Estados Unidos</td>\n",
       "      <td>Norteamérica</td>\n",
       "      <td>72.8</td>\n",
       "      <td>8.21</td>\n",
       "      <td>7.39</td>\n",
       "      <td>60.0</td>\n",
       "      <td>0.704</td>\n",
       "      <td>86</td>\n",
       "      <td>7.65</td>\n",
       "      <td>...</td>\n",
       "      <td>Más Tradicional | Autoexpresión</td>\n",
       "      <td>76.38</td>\n",
       "      <td>66.95</td>\n",
       "      <td>86.0</td>\n",
       "      <td>76.44</td>\n",
       "      <td>75.48</td>\n",
       "      <td>79.79</td>\n",
       "      <td>76.73</td>\n",
       "      <td>True</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Lithuania</td>\n",
       "      <td>Lituania</td>\n",
       "      <td>Europa</td>\n",
       "      <td>75.0</td>\n",
       "      <td>7.82</td>\n",
       "      <td>6.75</td>\n",
       "      <td>55.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>91</td>\n",
       "      <td>7.55</td>\n",
       "      <td>...</td>\n",
       "      <td>Secular-Racional | Supervivencia-Mixto</td>\n",
       "      <td>73.87</td>\n",
       "      <td>61.25</td>\n",
       "      <td>91.0</td>\n",
       "      <td>75.37</td>\n",
       "      <td>73.51</td>\n",
       "      <td>80.77</td>\n",
       "      <td>NaN</td>\n",
       "      <td>True</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Taiwan</td>\n",
       "      <td>Taiwán</td>\n",
       "      <td>Asia-Pacífico</td>\n",
       "      <td>79.8</td>\n",
       "      <td>7.90</td>\n",
       "      <td>7.57</td>\n",
       "      <td>40.0</td>\n",
       "      <td>0.591</td>\n",
       "      <td>89</td>\n",
       "      <td>8.78</td>\n",
       "      <td>...</td>\n",
       "      <td>Secular-Confuciano | Seguridad</td>\n",
       "      <td>78.29</td>\n",
       "      <td>57.85</td>\n",
       "      <td>89.0</td>\n",
       "      <td>75.05</td>\n",
       "      <td>74.30</td>\n",
       "      <td>80.09</td>\n",
       "      <td>74.89</td>\n",
       "      <td>True</td>\n",
       "      <td>5.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      country_en            pais         region  heritage_2026  fraser_2026  \\\n",
       "0    Switzerland           Suiza         Europa           83.7         8.45   \n",
       "1      Singapore        Singapur  Asia-Pacífico           84.4         8.43   \n",
       "2  United States  Estados Unidos   Norteamérica           72.8         8.21   \n",
       "3      Lithuania        Lituania         Europa           75.0         7.82   \n",
       "4         Taiwan          Taiwán  Asia-Pacífico           79.8         7.90   \n",
       "\n",
       "   fraser_tamano_estado  hofstede_idv_2023  giem_wvs  gallup_ley_orden_2025  \\\n",
       "0                  7.67               79.0     0.573                     91   \n",
       "1                  7.38               43.0       NaN                     95   \n",
       "2                  7.39               60.0     0.704                     86   \n",
       "3                  6.75               55.0       NaN                     91   \n",
       "4                  7.57               40.0     0.591                     89   \n",
       "\n",
       "   eiu_democracia_2025  ...                         eje_cultural_iw  \\\n",
       "0                 9.32  ...        Secular-Racional | Autoexpresión   \n",
       "1                 6.18  ...          Confuciano | Restricción/Orden   \n",
       "2                 7.65  ...         Más Tradicional | Autoexpresión   \n",
       "3                 7.55  ...  Secular-Racional | Supervivencia-Mixto   \n",
       "4                 8.78  ...          Secular-Confuciano | Seguridad   \n",
       "\n",
       "  pilar1_libre_mercado  pilar2_resp_individual  pilar3_ley_orden  isid_base  \\\n",
       "0                81.88                   77.85              91.0      83.58   \n",
       "1                81.18                   58.40              95.0      78.19   \n",
       "2                76.38                   66.95              86.0      76.44   \n",
       "3                73.87                   61.25              91.0      75.37   \n",
       "4                78.29                   57.85              89.0      75.05   \n",
       "\n",
       "   isid_mercado  isid_ley_orden  isid_giem  cumple_filtro_antiestatista  \\\n",
       "0         82.49           86.09      81.20                         True   \n",
       "1         77.11           84.23        NaN                         True   \n",
       "2         75.48           79.79      76.73                         True   \n",
       "3         73.51           80.77        NaN                         True   \n",
       "4         74.30           80.09      74.89                         True   \n",
       "\n",
       "   ranking_isid_filtrado  \n",
       "0                    1.0  \n",
       "1                    2.0  \n",
       "2                    3.0  \n",
       "3                    4.0  \n",
       "4                    5.0  \n",
       "\n",
       "[5 rows x 21 columns]"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import plotly.express as px\n",
    "import plotly.graph_objects as go\n",
    "\n",
    "DATA_PATH = Path('../data/ideologia_global_2026.csv')\n",
    "CHARTS_DIR = Path('../charts')\n",
    "CHARTS_DIR.mkdir(parents=True, exist_ok=True)\n",
    "\n",
    "df = pd.read_csv(DATA_PATH)\n",
    "print(f'Países cargados: {len(df)}')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "cell-recalc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-22T12:44:50.783036Z",
     "iopub.status.busy": "2026-11-22T12:44:50.782636Z",
     "iopub.status.idle": "2026-11-22T12:44:50.794846Z",
     "shell.execute_reply": "2026-11-22T12:44:50.794320Z"
    }
   },
   "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>pais</th>\n",
       "      <th>isid_calc</th>\n",
       "      <th>p1_calc</th>\n",
       "      <th>p2_calc</th>\n",
       "      <th>p3_calc</th>\n",
       "      <th>fraser_tamano_estado</th>\n",
       "      <th>eiu_democracia_2025</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Suiza</td>\n",
       "      <td>83.58</td>\n",
       "      <td>81.88</td>\n",
       "      <td>77.85</td>\n",
       "      <td>91</td>\n",
       "      <td>7.67</td>\n",
       "      <td>9.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Singapur</td>\n",
       "      <td>78.19</td>\n",
       "      <td>81.18</td>\n",
       "      <td>58.40</td>\n",
       "      <td>95</td>\n",
       "      <td>7.38</td>\n",
       "      <td>6.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Estados Unidos</td>\n",
       "      <td>76.44</td>\n",
       "      <td>76.38</td>\n",
       "      <td>66.95</td>\n",
       "      <td>86</td>\n",
       "      <td>7.39</td>\n",
       "      <td>7.65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Lituania</td>\n",
       "      <td>75.37</td>\n",
       "      <td>73.87</td>\n",
       "      <td>61.25</td>\n",
       "      <td>91</td>\n",
       "      <td>6.75</td>\n",
       "      <td>7.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Taiwán</td>\n",
       "      <td>75.05</td>\n",
       "      <td>78.29</td>\n",
       "      <td>57.85</td>\n",
       "      <td>89</td>\n",
       "      <td>7.57</td>\n",
       "      <td>8.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Canadá</td>\n",
       "      <td>74.85</td>\n",
       "      <td>73.00</td>\n",
       "      <td>67.55</td>\n",
       "      <td>84</td>\n",
       "      <td>6.31</td>\n",
       "      <td>9.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>Estonia</td>\n",
       "      <td>74.66</td>\n",
       "      <td>73.97</td>\n",
       "      <td>62.00</td>\n",
       "      <td>88</td>\n",
       "      <td>6.20</td>\n",
       "      <td>8.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Nueva Zelanda</td>\n",
       "      <td>74.43</td>\n",
       "      <td>75.44</td>\n",
       "      <td>65.85</td>\n",
       "      <td>82</td>\n",
       "      <td>6.27</td>\n",
       "      <td>9.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>República Checa</td>\n",
       "      <td>73.64</td>\n",
       "      <td>71.27</td>\n",
       "      <td>65.65</td>\n",
       "      <td>84</td>\n",
       "      <td>6.13</td>\n",
       "      <td>8.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Australia</td>\n",
       "      <td>73.37</td>\n",
       "      <td>74.76</td>\n",
       "      <td>67.35</td>\n",
       "      <td>78</td>\n",
       "      <td>6.17</td>\n",
       "      <td>8.85</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              pais  isid_calc  p1_calc  p2_calc  p3_calc  \\\n",
       "0            Suiza      83.58    81.88    77.85       91   \n",
       "1         Singapur      78.19    81.18    58.40       95   \n",
       "2   Estados Unidos      76.44    76.38    66.95       86   \n",
       "3         Lituania      75.37    73.87    61.25       91   \n",
       "4           Taiwán      75.05    78.29    57.85       89   \n",
       "5           Canadá      74.85    73.00    67.55       84   \n",
       "6          Estonia      74.66    73.97    62.00       88   \n",
       "7    Nueva Zelanda      74.43    75.44    65.85       82   \n",
       "8  República Checa      73.64    71.27    65.65       84   \n",
       "9        Australia      73.37    74.76    67.35       78   \n",
       "\n",
       "   fraser_tamano_estado  eiu_democracia_2025  \n",
       "0                  7.67                 9.32  \n",
       "1                  7.38                 6.18  \n",
       "2                  7.39                 7.65  \n",
       "3                  6.75                 7.55  \n",
       "4                  7.57                 8.78  \n",
       "5                  6.31                 9.08  \n",
       "6                  6.20                 8.07  \n",
       "7                  6.27                 9.62  \n",
       "8                  6.13                 8.15  \n",
       "9                  6.17                 8.85  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Recálculo transparente de pilares y pruebas de sensibilidad\n",
    "df['p1_calc'] = 0.35 * df['heritage_2026'] + 0.35 * (df['fraser_2026'] * 10) + 0.30 * (df['fraser_tamano_estado'] * 10)\n",
    "df['p2_calc'] = 0.50 * df['hofstede_idv_2023'] + 0.50 * (df['fraser_tamano_estado'] * 10)\n",
    "df['p3_calc'] = df['gallup_ley_orden_2025']\n",
    "\n",
    "df['isid_calc'] = (df['p1_calc'] + df['p2_calc'] + df['p3_calc']) / 3.0\n",
    "df['isid_mercado_calc'] = 0.50 * df['p1_calc'] + 0.30 * df['p2_calc'] + 0.20 * df['p3_calc']\n",
    "df['isid_orden_calc'] = 0.25 * df['p1_calc'] + 0.20 * df['p2_calc'] + 0.55 * df['p3_calc']\n",
    "\n",
    "top10 = (\n",
    "    df[(df['fraser_tamano_estado'] >= 6.0) & df['isid_calc'].notna()]\n",
    "    .sort_values('isid_calc', ascending=False)\n",
    "    .head(10)\n",
    "    .copy()\n",
    ")\n",
    "top10[['pais', 'isid_calc', 'p1_calc', 'p2_calc', 'p3_calc', 'fraser_tamano_estado', 'eiu_democracia_2025']].round(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cell-corr",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-22T12:44:50.796122Z",
     "iopub.status.busy": "2026-11-22T12:44:50.796007Z",
     "iopub.status.idle": "2026-11-22T12:44:50.803140Z",
     "shell.execute_reply": "2026-11-22T12:44:50.802231Z"
    }
   },
   "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>heritage_2026</th>\n",
       "      <th>fraser_2026</th>\n",
       "      <th>hofstede_idv_2023</th>\n",
       "      <th>gallup_ley_orden_2025</th>\n",
       "      <th>eiu_democracia_2025</th>\n",
       "      <th>confianza_social_wvs</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>heritage_2026</th>\n",
       "      <td>1.000</td>\n",
       "      <td>0.857</td>\n",
       "      <td>0.434</td>\n",
       "      <td>0.401</td>\n",
       "      <td>0.637</td>\n",
       "      <td>0.367</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>fraser_2026</th>\n",
       "      <td>0.857</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.437</td>\n",
       "      <td>0.240</td>\n",
       "      <td>0.705</td>\n",
       "      <td>0.270</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>hofstede_idv_2023</th>\n",
       "      <td>0.434</td>\n",
       "      <td>0.437</td>\n",
       "      <td>1.000</td>\n",
       "      <td>-0.017</td>\n",
       "      <td>0.690</td>\n",
       "      <td>0.615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>gallup_ley_orden_2025</th>\n",
       "      <td>0.401</td>\n",
       "      <td>0.240</td>\n",
       "      <td>-0.017</td>\n",
       "      <td>1.000</td>\n",
       "      <td>-0.079</td>\n",
       "      <td>0.290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>eiu_democracia_2025</th>\n",
       "      <td>0.637</td>\n",
       "      <td>0.705</td>\n",
       "      <td>0.690</td>\n",
       "      <td>-0.079</td>\n",
       "      <td>1.000</td>\n",
       "      <td>0.283</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>confianza_social_wvs</th>\n",
       "      <td>0.367</td>\n",
       "      <td>0.270</td>\n",
       "      <td>0.615</td>\n",
       "      <td>0.290</td>\n",
       "      <td>0.283</td>\n",
       "      <td>1.000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       heritage_2026  fraser_2026  hofstede_idv_2023  \\\n",
       "heritage_2026                  1.000        0.857              0.434   \n",
       "fraser_2026                    0.857        1.000              0.437   \n",
       "hofstede_idv_2023              0.434        0.437              1.000   \n",
       "gallup_ley_orden_2025          0.401        0.240             -0.017   \n",
       "eiu_democracia_2025            0.637        0.705              0.690   \n",
       "confianza_social_wvs           0.367        0.270              0.615   \n",
       "\n",
       "                       gallup_ley_orden_2025  eiu_democracia_2025  \\\n",
       "heritage_2026                          0.401                0.637   \n",
       "fraser_2026                            0.240                0.705   \n",
       "hofstede_idv_2023                     -0.017                0.690   \n",
       "gallup_ley_orden_2025                  1.000               -0.079   \n",
       "eiu_democracia_2025                   -0.079                1.000   \n",
       "confianza_social_wvs                   0.290                0.283   \n",
       "\n",
       "                       confianza_social_wvs  \n",
       "heritage_2026                         0.367  \n",
       "fraser_2026                           0.270  \n",
       "hofstede_idv_2023                     0.615  \n",
       "gallup_ley_orden_2025                 0.290  \n",
       "eiu_democracia_2025                   0.283  \n",
       "confianza_social_wvs                  1.000  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Matriz de correlaciones entre ejes (muestra con datos de individualismo)\n",
    "cols_corr = [\n",
    "    'heritage_2026', 'fraser_2026', 'hofstede_idv_2023',\n",
    "    'gallup_ley_orden_2025', 'eiu_democracia_2025', 'confianza_social_wvs'\n",
    "]\n",
    "corr_matrix = df.dropna(subset=['hofstede_idv_2023'])[cols_corr].corr().round(3)\n",
    "corr_matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cell-chart-1",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-22T12:44:50.804752Z",
     "iopub.status.busy": "2026-11-22T12:44:50.804422Z",
     "iopub.status.idle": "2026-11-22T12:44:52.633929Z",
     "shell.execute_reply": "2026-11-22T12:44:52.633361Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "data": [
        {
         "customdata": {
          "bdata": "ZmZmZmbmIEAAAAAAAMBWQAAAAAAAgE1ASOF6FK5HH0AAAAAAAMBWQAAAAAAAAEBArkfhehSuH0AAAAAAAABWQAAAAAAAAEFAPQrXo3A9H0AAAAAAAABVQAAAAAAAADtA16NwPQrXH0AAAAAAAABUQAAAAAAAgEVAUrgehetRIEAAAAAAAIBUQAAAAAAAAPh/H4XrUbgeH0AAAAAAAABVQAAAAAAAgERAw/UoXI9CIEAAAAAAAIBWQAAAAAAAgFJA16NwPQrXH0AAAAAAAIBVQAAAAAAAgExAhetRuB6FH0AAAAAAAIBVQAAAAAAAAEVA16NwPQrXH0AAAAAAAIBWQAAAAAAAAFFArkfhehSuH0AAAAAAAABWQAAAAAAAAPh/pHA9CtejHkAAAAAAAABWQAAAAAAAgE9ArkfhehSuHkAAAAAAAMBWQAAAAAAAAFJAexSuR+F6HEAAAAAAAABVQAAAAAAAADhAcT0K16NwHUAAAAAAAIBUQAAAAAAAADtACtejcD0KHkAAAAAAAEBUQAAAAAAAADpA",
          "dtype": "f8",
          "shape": "17, 3"
         },
         "hovertemplate": "Región=Europa<br>Libertad Económica Heritage 2026 (0-100)=%{x}<br>Índice de Democracia EIU 2025 (0-10)=%{y}<br>tamano_punto=%{marker.size}<br>pais=%{text}<br>fraser_2026=%{customdata[0]}<br>gallup_ley_orden_2025=%{customdata[1]}<br>confianza_social_wvs=%{customdata[2]}<extra></extra>",
         "legendgroup": "Europa",
         "marker": {
          "color": "#636efa",
          "size": {
           "bdata": "AAAAAACATUAAAAAAAABAQAAAAAAAAEFAAAAAAAAAO0AAAAAAAIBFQAAAAAAAAD5AAAAAAACAREAAAAAAAIBSQAAAAAAAgExAAAAAAAAARUAAAAAAAABRQAAAAAAAAD5AAAAAAACAT0AAAAAAAABSQAAAAAAAADhAAAAAAAAAO0AAAAAAAAA6QA==",
           "dtype": "f8"
          },
          "sizemode": "area",
          "sizeref": 0.185,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "Europa",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Suiza",
          "Lituania",
          "Estonia",
          "República Checa",
          "Reino Unido",
          "Irlanda",
          "España",
          "Dinamarca",
          "Países Bajos",
          "Alemania",
          "Finlandia",
          "Luxemburgo",
          "Suecia",
          "Noruega",
          "Polonia",
          "Hungría",
          "Francia"
         ],
         "textfont": {
          "size": 10
         },
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "zczMzMzsVEAAAAAAAMBSQAAAAAAAwFNAAAAAAABAUkAAAAAAAIBRQDMzMzMz01RAMzMzMzOzUEAAAAAAAMBTQAAAAAAAwFNAAAAAAAAAUkBmZmZmZiZTQM3MzMzM7FNAAAAAAACAU0AAAAAAAMBTQAAAAAAAQFFAAAAAAACAT0AAAAAAAEBQQA==",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "pHA9CtejIkAzMzMzMzMeQKRwPQrXIyBAzczMzMxMIECuR+F6FK4gQClcj8L1qCJAZmZmZmZmIEDXo3A9CtciQFyPwvUo3CFA9ihcj8J1IUA9CtejcL0iQClcj8L1KCJAMzMzMzOzIkAfhetRuJ4jQJqZmZmZmR5AUrgehetRGkCamZmZmRkgQA==",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "customdata": {
          "bdata": "XI/C9SjcIEAAAAAAAMBXQAAAAAAAAEFAmpmZmZmZH0AAAAAAAEBWQAAAAAAAAD9Aw/UoXI/CIEAAAAAAAIBUQAAAAAAAgExAH4XrUbgeIEAAAAAAAIBTQAAAAAAAgEhAzczMzMzMH0AAAAAAAABWQAAAAAAAAEFA4XoUrkfhHUAAAAAAAABWQAAAAAAAgEBAuB6F61G4GEAAAAAAAABTQAAAAAAAgE9A",
          "dtype": "f8",
          "shape": "7, 3"
         },
         "hovertemplate": "Región=Asia-Pacífico<br>Libertad Económica Heritage 2026 (0-100)=%{x}<br>Índice de Democracia EIU 2025 (0-10)=%{y}<br>tamano_punto=%{marker.size}<br>pais=%{text}<br>fraser_2026=%{customdata[0]}<br>gallup_ley_orden_2025=%{customdata[1]}<br>confianza_social_wvs=%{customdata[2]}<extra></extra>",
         "legendgroup": "Asia-Pacífico",
         "marker": {
          "color": "#EF553B",
          "size": {
           "bdata": "AAAAAAAAQUAAAAAAAAA/QAAAAAAAgExAAAAAAACASEAAAAAAAABBQAAAAAAAgEBAAAAAAACAT0A=",
           "dtype": "f8"
          },
          "sizemode": "area",
          "sizeref": 0.185,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "Asia-Pacífico",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Singapur",
          "Taiwán",
          "Nueva Zelanda",
          "Australia",
          "Japón",
          "Corea del Sur",
          "China"
         ],
         "textfont": {
          "size": 10
         },
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "mpmZmZkZVUAzMzMzM/NTQAAAAAAAgFNAZmZmZmYGVEAzMzMzM5NRQAAAAAAAgFJAZmZmZmYmSEA=",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "uB6F61G4GECPwvUoXI8hQD0K16NwPSNAMzMzMzOzIUAzMzMzM7MhQAAAAAAAAB9A4XoUrkfhAEA=",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "customdata": {
          "bdata": "7FG4HoVrIEAAAAAAAIBVQAAAAAAAgEJAj8L1KFyPH0AAAAAAAABVQAAAAAAAgEdA",
          "dtype": "f8",
          "shape": "2, 3"
         },
         "hovertemplate": "Región=Norteamérica<br>Libertad Económica Heritage 2026 (0-100)=%{x}<br>Índice de Democracia EIU 2025 (0-10)=%{y}<br>tamano_punto=%{marker.size}<br>pais=%{text}<br>fraser_2026=%{customdata[0]}<br>gallup_ley_orden_2025=%{customdata[1]}<br>confianza_social_wvs=%{customdata[2]}<extra></extra>",
         "legendgroup": "Norteamérica",
         "marker": {
          "color": "#00cc96",
          "size": {
           "bdata": "AAAAAACAQkAAAAAAAIBHQA==",
           "dtype": "f8"
          },
          "sizemode": "area",
          "sizeref": 0.185,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "Norteamérica",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Estados Unidos",
          "Canadá"
         ],
         "textfont": {
          "size": 10
         },
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "MzMzMzMzUkBmZmZmZuZSQA==",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "mpmZmZmZHkApXI/C9SgiQA==",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "customdata": {
          "bdata": "ZmZmZmZmH0AAAAAAAMBRQAAAAAAAAPh/cT0K16NwHEAAAAAAAABXQAAAAAAAAPh/UrgehetRGkAAAAAAAIBSQAAAAAAAABxA",
          "dtype": "f8",
          "shape": "3, 3"
         },
         "hovertemplate": "Región=Latinoamérica<br>Libertad Económica Heritage 2026 (0-100)=%{x}<br>Índice de Democracia EIU 2025 (0-10)=%{y}<br>tamano_punto=%{marker.size}<br>pais=%{text}<br>fraser_2026=%{customdata[0]}<br>gallup_ley_orden_2025=%{customdata[1]}<br>confianza_social_wvs=%{customdata[2]}<extra></extra>",
         "legendgroup": "Latinoamérica",
         "marker": {
          "color": "#ab63fa",
          "size": {
           "bdata": "AAAAAAAAPkAAAAAAAAA+QAAAAAAAABxA",
           "dtype": "f8"
          },
          "sizemode": "area",
          "sizeref": 0.185,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "Latinoamérica",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Chile",
          "El Salvador",
          "Brasil"
         ],
         "textfont": {
          "size": 10
         },
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "MzMzMzOTUkCamZmZmdlMQDMzMzMzM0pA",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "4XoUrkfhH0BI4XoUrkcSQArXo3A9ChtA",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "customdata": {
          "bdata": "CtejcD0KH0AAAAAAAIBVQAAAAAAAAPh/",
          "dtype": "f8",
          "shape": "1, 3"
         },
         "hovertemplate": "Región=Eurasia<br>Libertad Económica Heritage 2026 (0-100)=%{x}<br>Índice de Democracia EIU 2025 (0-10)=%{y}<br>tamano_punto=%{marker.size}<br>pais=%{text}<br>fraser_2026=%{customdata[0]}<br>gallup_ley_orden_2025=%{customdata[1]}<br>confianza_social_wvs=%{customdata[2]}<extra></extra>",
         "legendgroup": "Eurasia",
         "marker": {
          "color": "#FFA15A",
          "size": {
           "bdata": "AAAAAAAAPkA=",
           "dtype": "f8"
          },
          "sizemode": "area",
          "sizeref": 0.185,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "Eurasia",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Georgia"
         ],
         "textfont": {
          "size": 10
         },
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "AAAAAACAUUA=",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "cT0K16NwEUA=",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "customdata": {
          "bdata": "ZmZmZmZmHUAAAAAAAMBXQAAAAAAAAPh/SOF6FK5HHkAAAAAAAIBUQAAAAAAAAPh/j8L1KFyPGkAAAAAAAABXQAAAAAAAAPh/",
          "dtype": "f8",
          "shape": "3, 3"
         },
         "hovertemplate": "Región=MENA<br>Libertad Económica Heritage 2026 (0-100)=%{x}<br>Índice de Democracia EIU 2025 (0-10)=%{y}<br>tamano_punto=%{marker.size}<br>pais=%{text}<br>fraser_2026=%{customdata[0]}<br>gallup_ley_orden_2025=%{customdata[1]}<br>confianza_social_wvs=%{customdata[2]}<extra></extra>",
         "legendgroup": "MENA",
         "marker": {
          "color": "#19d3f3",
          "size": {
           "bdata": "AAAAAAAAPkAAAAAAAAA+QAAAAAAAAD5A",
           "dtype": "f8"
          },
          "sizemode": "area",
          "sizeref": 0.185,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "MENA",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Emiratos Árabes Unidos",
          "Israel",
          "Arabia Saudí"
         ],
         "textfont": {
          "size": 10
         },
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "AAAAAAAAUkAAAAAAAABRQAAAAAAAQFBA",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "cT0K16NwCUAzMzMzMzMfQKRwPQrXowBA",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "customdata": {
          "bdata": "4XoUrkfhH0AAAAAAAABUQAAAAAAAAPh/",
          "dtype": "f8",
          "shape": "1, 3"
         },
         "hovertemplate": "Región=África<br>Libertad Económica Heritage 2026 (0-100)=%{x}<br>Índice de Democracia EIU 2025 (0-10)=%{y}<br>tamano_punto=%{marker.size}<br>pais=%{text}<br>fraser_2026=%{customdata[0]}<br>gallup_ley_orden_2025=%{customdata[1]}<br>confianza_social_wvs=%{customdata[2]}<extra></extra>",
         "legendgroup": "África",
         "marker": {
          "color": "#FF6692",
          "size": {
           "bdata": "AAAAAAAAPkA=",
           "dtype": "f8"
          },
          "sizemode": "area",
          "sizeref": 0.185,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "África",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Mauricio"
         ],
         "textfont": {
          "size": 10
         },
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "AAAAAABAUkA=",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "9ihcj8J1IEA=",
          "dtype": "f8"
         },
         "yaxis": "y"
        }
       ],
       "layout": {
        "legend": {
         "itemsizing": "constant",
         "title": {
          "text": "Región"
         },
         "tracegroupgap": 0
        },
        "shapes": [
         {
          "line": {
           "color": "#888888",
           "dash": "dash"
          },
          "type": "line",
          "x0": 70,
          "x1": 70,
          "xref": "x",
          "y0": 0,
          "y1": 1,
          "yref": "y domain"
         },
         {
          "line": {
           "color": "#888888",
           "dash": "dash"
          },
          "type": "line",
          "x0": 0,
          "x1": 1,
          "xref": "x domain",
          "y0": 8.0,
          "y1": 8.0,
          "yref": "y"
         }
        ],
        "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.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.0,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#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"
           }
          ],
          "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.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.0,
              "#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.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.0,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0.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.0,
             "#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",
          "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": "Libertad Económica (Heritage 2026) vs. Democracia (EIU 2025)"
        },
        "xaxis": {
         "anchor": "y",
         "domain": [
          0.0,
          1.0
         ],
         "title": {
          "text": "Libertad Económica Heritage 2026 (0-100)"
         }
        },
        "yaxis": {
         "anchor": "x",
         "domain": [
          0.0,
          1.0
         ],
         "title": {
          "text": "Índice de Democracia EIU 2025 (0-10)"
         }
        }
       }
      }
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Gráfico 1: Libertad económica vs. Democracia (tamaño = Confianza social)\n",
    "df_g1 = df.dropna(subset=['heritage_2026', 'eiu_democracia_2025']).copy()\n",
    "df_g1['tamano_punto'] = df_g1['confianza_social_wvs'].fillna(30)\n",
    "\n",
    "fig1 = px.scatter(\n",
    "    df_g1,\n",
    "    x='heritage_2026',\n",
    "    y='eiu_democracia_2025',\n",
    "    color='region',\n",
    "    size='tamano_punto',\n",
    "    text='pais',\n",
    "    hover_data=['fraser_2026', 'gallup_ley_orden_2025', 'confianza_social_wvs'],\n",
    "    title='Libertad Económica (Heritage 2026) vs. Democracia (EIU 2025)',\n",
    "    labels={\n",
    "        'heritage_2026': 'Libertad Económica Heritage 2026 (0-100)',\n",
    "        'eiu_democracia_2025': 'Índice de Democracia EIU 2025 (0-10)',\n",
    "        'region': 'Región'\n",
    "    },\n",
    "    template='plotly_white'\n",
    ")\n",
    "fig1.update_traces(textposition='top center', textfont_size=10)\n",
    "fig1.add_vline(x=70, line_dash='dash', line_color='#888888')\n",
    "fig1.add_hline(y=8.0, line_dash='dash', line_color='#888888')\n",
    "fig1.write_html(CHARTS_DIR / '01_mercado_democracia_confianza.html')\n",
    "fig1.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "cell-chart-2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-22T12:44:52.636234Z",
     "iopub.status.busy": "2026-11-22T12:44:52.636020Z",
     "iopub.status.idle": "2026-11-22T12:44:52.683596Z",
     "shell.execute_reply": "2026-11-22T12:44:52.682802Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "data": [
        {
         "customdata": {
          "bdata": "vHSTGARW4j+1gU4b6ORUQLpJDAIrh+Y/FK5H4XocU0AAAAAAAAD4f04b6LSBtlJAAAAAAAAA5D86baDTBqpSQAAAAAAAAOg/61G4HoWbUkAtsp3vp8bnPxERERERaVJAJzEIrBxa5D9fLPnFkldSQN9PjZduEuM/AAAAAABAUkBqvHSTGATWP5NfLPnFIlJA",
          "dtype": "f8",
          "shape": "9, 2"
         },
         "hovertemplate": "Cuadrante=Individualismo de Estado Limitado<br>Fraser Área 1: Tamaño del Estado (mayor = Estado más limitado)=%{x}<br>Individualismo Cultural 2023 (0-100)=%{y}<br>pais=%{text}<br>giem_wvs=%{customdata[0]}<br>isid_calc=%{customdata[1]}<extra></extra>",
         "legendgroup": "Individualismo de Estado Limitado",
         "marker": {
          "color": "#636efa",
          "size": 11,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "Individualismo de Estado Limitado",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Suiza",
          "Estados Unidos",
          "Canadá",
          "Estonia",
          "Nueva Zelanda",
          "República Checa",
          "Australia",
          "Reino Unido",
          "España"
         ],
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "rkfhehSuHkCPwvUoXI8dQD0K16NwPRlAzczMzMzMGEAUrkfhehQZQIXrUbgehRhArkfhehSuGEBSuB6F61EYQMP1KFyPwhhA",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "AAAAAADAU0AAAAAAAABOQAAAAAAAAFJAAAAAAAAAT0AAAAAAAEBRQAAAAAAAgFFAAAAAAABAUkAAAAAAAABTQAAAAAAAwFBA",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "customdata": {
          "bdata": "AAAAAAAA+H8UrkfheoxTQAAAAAAAAPh/GEt+seTXUkC28/3UeOniP2PJL5b8wlJAAAAAAAAA+H9RuB6F6zlSQMP1KFyPwtU/nTbQaQN9UUDNzMzMzMzkPzfQaQOd9lBA",
          "dtype": "f8",
          "shape": "6, 2"
         },
         "hovertemplate": "Cuadrante=Colectivismo Pro-Mercado<br>Fraser Área 1: Tamaño del Estado (mayor = Estado más limitado)=%{x}<br>Individualismo Cultural 2023 (0-100)=%{y}<br>pais=%{text}<br>giem_wvs=%{customdata[0]}<br>isid_calc=%{customdata[1]}<extra></extra>",
         "legendgroup": "Colectivismo Pro-Mercado",
         "marker": {
          "color": "#EF553B",
          "size": 11,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "Colectivismo Pro-Mercado",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Singapur",
          "Lituania",
          "Taiwán",
          "Irlanda",
          "Chile",
          "Georgia"
         ],
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "hetRuB6FHUAAAAAAAAAbQEjhehSuRx5AAAAAAAAAGUBxPQrXo3AeQDMzMzMzMx1A",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "AAAAAACARUAAAAAAAIBLQAAAAAAAAERAAAAAAAAATUAAAAAAAIBIQAAAAAAAAC5A",
          "dtype": "f8"
         },
         "yaxis": "y"
        },
        {
         "customdata": {
          "bdata": "+n5qvHST5D+h0wY6bXhTQClcj8L1KOA/IiIiIiJyU0D+1HjpJjHgP3h3d3d3t1JAAAAAAAAA+H9H4XoUrndSQFK4HoXrUeA/61G4HoU7UkAAAAAAAAD4f3TaQKcNvFFA",
          "dtype": "f8",
          "shape": "6, 2"
         },
         "hovertemplate": "Cuadrante=Individualismo Estatista (< 6.0)<br>Fraser Área 1: Tamaño del Estado (mayor = Estado más limitado)=%{x}<br>Individualismo Cultural 2023 (0-100)=%{y}<br>pais=%{text}<br>giem_wvs=%{customdata[0]}<br>isid_calc=%{customdata[1]}<extra></extra>",
         "legendgroup": "Individualismo Estatista (< 6.0)",
         "marker": {
          "color": "#00cc96",
          "size": 11,
          "symbol": "circle"
         },
         "mode": "markers+text",
         "name": "Individualismo Estatista (< 6.0)",
         "orientation": "v",
         "showlegend": true,
         "text": [
          "Dinamarca",
          "Países Bajos",
          "Alemania",
          "Finlandia",
          "Japón",
          "Luxemburgo"
         ],
         "textposition": "top center",
         "type": "scatter",
         "x": {
          "bdata": "hetRuB6FFUDsUbgehesUQClcj8L1KBdAuB6F61G4E0CuR+F6FK4XQJqZmZmZmRNA",
          "dtype": "f8"
         },
         "xaxis": "x",
         "y": {
          "bdata": "AAAAAABAVkAAAAAAAABZQAAAAAAAwFNAAAAAAADAUkAAAAAAAABPQAAAAAAAAE5A",
          "dtype": "f8"
         },
         "yaxis": "y"
        }
       ],
       "layout": {
        "annotations": [
         {
          "showarrow": false,
          "text": "Umbral 6.0",
          "x": 6.0,
          "xanchor": "left",
          "xref": "x",
          "y": 1,
          "yanchor": "top",
          "yref": "y domain"
         }
        ],
        "legend": {
         "title": {
          "text": "Cuadrante"
         },
         "tracegroupgap": 0
        },
        "shapes": [
         {
          "line": {
           "color": "#666666",
           "dash": "dash"
          },
          "type": "line",
          "x0": 6.0,
          "x1": 6.0,
          "xref": "x",
          "y0": 0,
          "y1": 1,
          "yref": "y domain"
         },
         {
          "line": {
           "color": "#666666",
           "dash": "dash"
          },
          "type": "line",
          "x0": 0,
          "x1": 1,
          "xref": "x domain",
          "y0": 60,
          "y1": 60,
          "yref": "y"
         }
        ],
        "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.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.0,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#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"
           }
          ],
          "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.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.0,
              "#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.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.0,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0.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.0,
             "#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",
          "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": "Contención Fiscal del Estado vs. Individualismo Cultural (2023)"
        },
        "xaxis": {
         "anchor": "y",
         "domain": [
          0.0,
          1.0
         ],
         "title": {
          "text": "Fraser Área 1: Tamaño del Estado (mayor = Estado más limitado)"
         }
        },
        "yaxis": {
         "anchor": "x",
         "domain": [
          0.0,
          1.0
         ],
         "title": {
          "text": "Individualismo Cultural 2023 (0-100)"
         }
        }
       }
      }
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Gráfico 2: Contención fiscal (Fraser Tamaño del Estado) vs. Individualismo (2023)\n",
    "df_g2 = df.dropna(subset=['fraser_tamano_estado', 'hofstede_idv_2023']).copy()\n",
    "df_g2['perfil'] = np.where(\n",
    "    df_g2['fraser_tamano_estado'] < 6.0,\n",
    "    'Individualismo Estatista (< 6.0)',\n",
    "    np.where(df_g2['hofstede_idv_2023'] >= 60, 'Individualismo de Estado Limitado', 'Colectivismo Pro-Mercado')\n",
    ")\n",
    "\n",
    "fig2 = px.scatter(\n",
    "    df_g2,\n",
    "    x='fraser_tamano_estado',\n",
    "    y='hofstede_idv_2023',\n",
    "    color='perfil',\n",
    "    text='pais',\n",
    "    hover_data=['giem_wvs', 'isid_calc'],\n",
    "    title='Contención Fiscal del Estado vs. Individualismo Cultural (2023)',\n",
    "    labels={\n",
    "        'fraser_tamano_estado': 'Fraser Área 1: Tamaño del Estado (mayor = Estado más limitado)',\n",
    "        'hofstede_idv_2023': 'Individualismo Cultural 2023 (0-100)',\n",
    "        'perfil': 'Cuadrante'\n",
    "    },\n",
    "    template='plotly_white'\n",
    ")\n",
    "fig2.update_traces(textposition='top center', marker_size=11)\n",
    "fig2.add_vline(x=6.0, line_dash='dash', line_color='#666666', annotation_text='Umbral 6.0')\n",
    "fig2.add_hline(y=60, line_dash='dash', line_color='#666666')\n",
    "fig2.write_html(CHARTS_DIR / '02_individualismo_estado_giem.html')\n",
    "fig2.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cell-chart-3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-11-22T12:44:52.686000Z",
     "iopub.status.busy": "2026-11-22T12:44:52.685847Z",
     "iopub.status.idle": "2026-11-22T12:44:52.720302Z",
     "shell.execute_reply": "2026-11-22T12:44:52.719026Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "data": [
        {
         "marker": {
          "color": "#1A73E8"
         },
         "name": "ISID Equilibrado (33/33/33)",
         "orientation": "h",
         "text": {
          "bdata": "SOF6FK5XUkApXI/C9WhSQOxRuB6Fm1JACtejcD2qUkBmZmZmZrZSQDMzMzMzw1JASOF6FK7XUkBcj8L1KBxTQFyPwvUojFNAhetRuB7lVEA=",
          "dtype": "f8"
         },
         "textposition": "outside",
         "type": "bar",
         "x": {
          "bdata": "SOF6FK5XUkApXI/C9WhSQOxRuB6Fm1JACtejcD2qUkBmZmZmZrZSQDMzMzMzw1JASOF6FK7XUkBcj8L1KBxTQFyPwvUojFNAhetRuB7lVEA=",
          "dtype": "f8"
         },
         "y": [
          "Australia",
          "República Checa",
          "Nueva Zelanda",
          "Estonia",
          "Canadá",
          "Taiwán",
          "Lituania",
          "Estados Unidos",
          "Singapur",
          "Suiza"
         ]
        },
        {
         "marker": {
          "color": "#12B5CB",
          "size": 10,
          "symbol": "diamond"
         },
         "mode": "markers",
         "name": "Énfasis Libre Mercado (50/30/20)",
         "type": "scatter",
         "x": {
          "bdata": "7FG4HoVLUkC4HoXrUQhSQLgehetReFJA7FG4HoVLUkAUrkfhemRSQDMzMzMzk1JAcT0K16NgUkAfhetRuN5SQNejcD0KR1NAj8L1KFyfVEA=",
          "dtype": "f8"
         },
         "y": [
          "Australia",
          "República Checa",
          "Nueva Zelanda",
          "Estonia",
          "Canadá",
          "Taiwán",
          "Lituania",
          "Estados Unidos",
          "Singapur",
          "Suiza"
         ]
        },
        {
         "marker": {
          "color": "#FA903E",
          "size": 10,
          "symbol": "circle"
         },
         "mode": "markers",
         "name": "Énfasis Ley y Orden (25/20/55)",
         "type": "scatter",
         "x": {
          "bdata": "pHA9CtfDUkCamZmZmUlTQLgehetRSFNAw/UoXI/SU0A9CtejcH1TQPYoXI/CBVRA4XoUrkcxVEDD9Shcj/JTQB+F61G4DlVA9ihcj8KFVUA=",
          "dtype": "f8"
         },
         "y": [
          "Australia",
          "República Checa",
          "Nueva Zelanda",
          "Estonia",
          "Canadá",
          "Taiwán",
          "Lituania",
          "Estados Unidos",
          "Singapur",
          "Suiza"
         ]
        }
       ],
       "layout": {
        "legend": {
         "orientation": "h",
         "x": 1,
         "xanchor": "right",
         "y": 1.02,
         "yanchor": "bottom"
        },
        "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.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.0,
              "#f0f921"
             ]
            ],
            "type": "contour"
           }
          ],
          "contourcarpet": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "type": "contourcarpet"
           }
          ],
          "heatmap": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#f0f921"
             ]
            ],
            "type": "heatmap"
           }
          ],
          "histogram": [
           {
            "marker": {
             "pattern": {
              "fillmode": "overlay",
              "size": 10,
              "solidity": 0.2
             }
            },
            "type": "histogram"
           }
          ],
          "histogram2d": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#f0f921"
             ]
            ],
            "type": "histogram2d"
           }
          ],
          "histogram2dcontour": [
           {
            "colorbar": {
             "outlinewidth": 0,
             "ticks": ""
            },
            "colorscale": [
             [
              0.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.0,
              "#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"
           }
          ],
          "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.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.0,
              "#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.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.0,
             "#f0f921"
            ]
           ],
           "sequentialminus": [
            [
             0.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.0,
             "#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",
          "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": "Top 10 Países por Orientación de Derechas (ISID 2026) y Sensibilidad"
        },
        "xaxis": {
         "range": [
          65,
          90
         ],
         "title": {
          "text": "Puntuación (0-100)"
         }
        },
        "yaxis": {
         "title": {
          "text": ""
         }
        }
       }
      }
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Gráfico 3: Ranking Top 10 ISID y análisis de sensibilidad por ponderación\n",
    "top10_plot = top10.iloc[::-1]\n",
    "\n",
    "fig3 = go.Figure()\n",
    "fig3.add_trace(go.Bar(\n",
    "    y=top10_plot['pais'],\n",
    "    x=top10_plot['isid_calc'].round(2),\n",
    "    orientation='h',\n",
    "    name='ISID Equilibrado (33/33/33)',\n",
    "    marker_color='#1A73E8',\n",
    "    text=top10_plot['isid_calc'].round(2),\n",
    "    textposition='outside'\n",
    "))\n",
    "fig3.add_trace(go.Scatter(\n",
    "    y=top10_plot['pais'],\n",
    "    x=top10_plot['isid_mercado_calc'].round(2),\n",
    "    mode='markers',\n",
    "    name='Énfasis Libre Mercado (50/30/20)',\n",
    "    marker=dict(color='#12B5CB', size=10, symbol='diamond')\n",
    "))\n",
    "fig3.add_trace(go.Scatter(\n",
    "    y=top10_plot['pais'],\n",
    "    x=top10_plot['isid_orden_calc'].round(2),\n",
    "    mode='markers',\n",
    "    name='Énfasis Ley y Orden (25/20/55)',\n",
    "    marker=dict(color='#FA903E', size=10, symbol='circle')\n",
    "))\n",
    "\n",
    "fig3.update_layout(\n",
    "    title='Top 10 Países por Orientación de Derechas (ISID 2026) y Sensibilidad',\n",
    "    xaxis=dict(title='Puntuación (0-100)', range=[65, 90]),\n",
    "    yaxis=dict(title=''),\n",
    "    template='plotly_white',\n",
    "    legend=dict(orientation='h', yanchor='bottom', y=1.02, xanchor='right', x=1)\n",
    ")\n",
    "fig3.write_html(CHARTS_DIR / '03_ranking_isid_sensibilidad.html')\n",
    "fig3.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.14.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
