IIabm/anova_visualization.ipynb

574 lines
1.3 MiB
Plaintext
Raw Normal View History

2023-07-08 16:23:44 +08:00
{
"cells": [
{
"cell_type": "code",
2023-08-22 21:04:34 +08:00
"execution_count": 6,
2023-07-08 16:23:44 +08:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>自变量</th>\n",
" <th>level</th>\n",
2023-08-19 10:35:48 +08:00
" <th>系统恢复用时R1</th>\n",
" <th>产业-企业边累计扰乱次数R2</th>\n",
" <th>产业-企业边最大传导深度R3</th>\n",
" <th>产业-企业边断裂总数R4</th>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>15</th>\n",
" <td>新供应关系构成概率P7</td>\n",
2023-07-08 16:23:44 +08:00
" <td>低</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.240</td>\n",
" <td>2.672</td>\n",
" <td>1.143</td>\n",
" <td>0.7640</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>16</th>\n",
" <td>新供应关系构成概率P7</td>\n",
2023-07-08 16:23:44 +08:00
" <td>中</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.132</td>\n",
" <td>2.674</td>\n",
" <td>1.143</td>\n",
" <td>0.7859</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>17</th>\n",
" <td>新供应关系构成概率P7</td>\n",
2023-07-08 16:23:44 +08:00
" <td>高</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.179</td>\n",
" <td>2.649</td>\n",
" <td>1.124</td>\n",
" <td>0.7575</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>9</th>\n",
" <td>是否已有连接偏好P4</td>\n",
" <td>不倾向</td>\n",
" <td>2.177</td>\n",
" <td>2.668</td>\n",
" <td>1.141</td>\n",
" <td>0.7804</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>是否已有连接偏好P4</td>\n",
" <td>倾向</td>\n",
" <td>2.191</td>\n",
" <td>2.663</td>\n",
" <td>1.133</td>\n",
" <td>0.7579</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>是否规模偏好P2</td>\n",
" <td>不倾向</td>\n",
" <td>2.171</td>\n",
" <td>2.669</td>\n",
" <td>1.137</td>\n",
" <td>0.7726</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>是否规模偏好P2</td>\n",
" <td>倾向</td>\n",
" <td>2.196</td>\n",
" <td>2.661</td>\n",
" <td>1.137</td>\n",
" <td>0.7657</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>最大尝试时间步P8</td>\n",
2023-07-08 16:23:44 +08:00
" <td>低</td>\n",
2023-08-19 10:35:48 +08:00
" <td>1.726</td>\n",
" <td>2.646</td>\n",
" <td>1.123</td>\n",
" <td>0.7782</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>19</th>\n",
" <td>最大尝试时间步P8</td>\n",
2023-07-08 16:23:44 +08:00
" <td>中</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.186</td>\n",
" <td>2.682</td>\n",
" <td>1.144</td>\n",
" <td>0.7599</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>20</th>\n",
" <td>最大尝试时间步P8</td>\n",
2023-07-08 16:23:44 +08:00
" <td>高</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.640</td>\n",
" <td>2.667</td>\n",
" <td>1.143</td>\n",
" <td>0.7694</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>7</th>\n",
" <td>最大尝试次数P3</td>\n",
" <td>低</td>\n",
" <td>2.286</td>\n",
" <td>2.691</td>\n",
" <td>1.154</td>\n",
" <td>0.8254</td>\n",
2023-07-10 14:47:23 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>6</th>\n",
" <td>最大尝试次数P3</td>\n",
" <td>中</td>\n",
" <td>2.124</td>\n",
" <td>2.652</td>\n",
" <td>1.127</td>\n",
" <td>0.7431</td>\n",
2023-07-10 14:47:23 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>5</th>\n",
" <td>最大尝试次数P3</td>\n",
" <td>高</td>\n",
" <td>2.141</td>\n",
" <td>2.652</td>\n",
" <td>1.130</td>\n",
" <td>0.7390</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
2023-07-10 14:47:23 +08:00
" <td>采购策略P1</td>\n",
2023-07-08 16:23:44 +08:00
" <td>单供应商</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.261</td>\n",
" <td>2.519</td>\n",
" <td>1.121</td>\n",
" <td>0.7919</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>1</th>\n",
2023-07-10 14:47:23 +08:00
" <td>采购策略P1</td>\n",
2023-07-08 16:23:44 +08:00
" <td>双供应商</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.146</td>\n",
" <td>2.650</td>\n",
" <td>1.133</td>\n",
" <td>0.7615</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>0</th>\n",
2023-07-10 14:47:23 +08:00
" <td>采购策略P1</td>\n",
2023-07-08 16:23:44 +08:00
" <td>三供应商</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.144</td>\n",
" <td>2.826</td>\n",
" <td>1.156</td>\n",
" <td>0.7541</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>10</th>\n",
" <td>额外产能分布P5</td>\n",
" <td>均匀分布</td>\n",
" <td>2.316</td>\n",
" <td>2.681</td>\n",
" <td>1.158</td>\n",
" <td>0.8403</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>额外产能分布P5</td>\n",
" <td>正态分布</td>\n",
" <td>2.052</td>\n",
" <td>2.650</td>\n",
" <td>1.115</td>\n",
" <td>0.6980</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>额外产能分布参数P6</td>\n",
2023-07-08 16:23:44 +08:00
" <td>低</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.436</td>\n",
" <td>2.705</td>\n",
" <td>1.171</td>\n",
" <td>0.9121</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>13</th>\n",
" <td>额外产能分布参数P6</td>\n",
2023-07-08 16:23:44 +08:00
" <td>中</td>\n",
2023-08-19 10:35:48 +08:00
" <td>2.202</td>\n",
" <td>2.666</td>\n",
" <td>1.142</td>\n",
" <td>0.7655</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" <tr>\n",
2023-08-19 10:35:48 +08:00
" <th>12</th>\n",
" <td>额外产能分布参数P6</td>\n",
2023-07-08 16:23:44 +08:00
" <td>高</td>\n",
2023-08-19 10:35:48 +08:00
" <td>1.914</td>\n",
" <td>2.624</td>\n",
" <td>1.098</td>\n",
" <td>0.6299</td>\n",
2023-07-08 16:23:44 +08:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
2023-08-19 10:35:48 +08:00
" 自变量 level 系统恢复用时R1 产业-企业边累计扰乱次数R2 产业-企业边最大传导深度R3 产业-企业边断裂总数R4\n",
"15 新供应关系构成概率P7 低 2.240 2.672 1.143 0.7640\n",
"16 新供应关系构成概率P7 中 2.132 2.674 1.143 0.7859\n",
"17 新供应关系构成概率P7 高 2.179 2.649 1.124 0.7575\n",
"9 是否已有连接偏好P4 不倾向 2.177 2.668 1.141 0.7804\n",
"8 是否已有连接偏好P4 倾向 2.191 2.663 1.133 0.7579\n",
"4 是否规模偏好P2 不倾向 2.171 2.669 1.137 0.7726\n",
"3 是否规模偏好P2 倾向 2.196 2.661 1.137 0.7657\n",
"18 最大尝试时间步P8 低 1.726 2.646 1.123 0.7782\n",
"19 最大尝试时间步P8 中 2.186 2.682 1.144 0.7599\n",
"20 最大尝试时间步P8 高 2.640 2.667 1.143 0.7694\n",
"7 最大尝试次数P3 低 2.286 2.691 1.154 0.8254\n",
"6 最大尝试次数P3 中 2.124 2.652 1.127 0.7431\n",
"5 最大尝试次数P3 高 2.141 2.652 1.130 0.7390\n",
"2 采购策略P1 单供应商 2.261 2.519 1.121 0.7919\n",
"1 采购策略P1 双供应商 2.146 2.650 1.133 0.7615\n",
"0 采购策略P1 三供应商 2.144 2.826 1.156 0.7541\n",
"10 额外产能分布P5 均匀分布 2.316 2.681 1.158 0.8403\n",
"11 额外产能分布P5 正态分布 2.052 2.650 1.115 0.6980\n",
"14 额外产能分布参数P6 低 2.436 2.705 1.171 0.9121\n",
"13 额外产能分布参数P6 中 2.202 2.666 1.142 0.7655\n",
"12 额外产能分布参数P6 高 1.914 2.624 1.098 0.6299"
2023-07-08 16:23:44 +08:00
]
},
2023-08-22 21:04:34 +08:00
"execution_count": 6,
2023-07-08 16:23:44 +08:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"\n",
"config = {\"figure.dpi\": 300,\n",
" \"font.family\": 'serif',\n",
" \"font.serif\": ['SimSun']}\n",
"df = pd.read_csv('analysis/anova_visualization.csv', encoding='utf-8-sig')\n",
"df['sort_index'] = df['level'].map({'不倾向':0,\n",
" '倾向':1,\n",
" '低':0,\n",
" '中':1,\n",
" '高':2,\n",
" '单供应商':0,\n",
" '双供应商':1,\n",
" '三供应商':2})\n",
"df.sort_values(['自变量', 'sort_index'], inplace=True)\n",
"df.drop(columns='sort_index', inplace=True)\n",
"df"
]
},
{
"cell_type": "code",
2023-08-22 21:04:34 +08:00
"execution_count": 11,
2023-07-08 16:23:44 +08:00
"metadata": {},
"outputs": [
2023-08-19 10:35:48 +08:00
{
2023-08-22 21:04:34 +08:00
"name": "stderr",
2023-08-19 10:35:48 +08:00
"output_type": "stream",
"text": [
2023-08-22 21:04:34 +08:00
"C:\\Users\\ASUS\\AppData\\Local\\Temp\\ipykernel_27216\\1808291987.py:10: UserWarning: \n",
"The markers list has fewer values (1) than needed (3) and will cycle, which may produce an uninterpretable plot.\n",
" ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n"
2023-08-19 10:35:48 +08:00
]
},
2023-07-08 16:23:44 +08:00
{
"data": {
2023-08-22 21:04:34 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABu4AAAVjCAYAAAAmTdnAAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzdeZyN5f/H8fdZZx9mYZixlUhF2iS+vpWQqEiLJFlaKZESbfYkvyjqWyllaReVSotSSoqSlDYREmObxcyY9ay/P8YcM845M+fMnDGD1/PxmIf73Pd9XffnDGnMe67rY3C73W4BAAAAAAAAAAAAqFHGmi4AAAAAAAAAAAAAAMEdAAAAAAAAAAAAUCsQ3AEAAAAAAAAAAAC1AMEdAA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JSUlBT1PZmamPv30U8/r7OxsZWZmHhPB3T///OMJ7SIjI/XBBx+ocePGNVwVAAAAgIoQ3AEAAABAFdhsNh08eFBZWVk6cOCAsrKylJWVpczMTGVmZiojI0MZGRnav3+/9u/fr+zsbL9zxcbG6uSTT1ZCQoLi4+OVmJio+Ph4JSQkeM6VvI6NjZXBYAi63vz8fF177bW6+OKLdcsttyghISGgccuWLdNzzz0nk8kkt9utK664wud9P/74o+e4WbNmuuuuuypVZ1XMmTPH09ctJSVFL730kuLj4/3en5GRofj4eK86X3vtNc9Kx//85z/63//+J5PJVO6zt23bpjp16gT8ea0uq1at8hz369eP0A4AAAA4RhDcAQAAAEAQvvrqK82YMUN5eXnKy8uTzWaT0WiU0WiU1WpVeHi4wsLCPL9GREQoMjJSrVu3VkxMjGJiYhQbG6uYmBjFxcUpMTHR82G1Wqu9fovF4nkfX331VdDjnU6nxowZoxYtWujUU0/1ul46uOvXr99RD+127typt99+W5IUERGh5557rtzQbteuXRo4cKAuueQSPfLII57zBw8e1KuvvipJatKkiZ588skKQ7utW7dq0KBBio+P16uvvqo6deqE4B1Vzscffyyp+Pd78ODBAY3Zv3+/li9frptuuqkaKwMAAABQHoI7AAAAAAjCxRdfrIsvvrjGnv/8888rMjJSAwcOrFQoVjocvPbaazV16tSAxo0ePVoffvihrFarnnzySZ+hnSStXr1akhQWFqY+ffoEXV9VPfbYY7Lb7ZKkW2+9VRaLRVu3bvV5b25urkaNGqXU1FS9+uqrioqK8vTie+6555STkyOz2az777/fs3LSnwMHDuiee+5RWlqa0tLSdOutt2r+/PmKjo4ut94lS5aoT58+FYaCpX3//fcqKCjw++dw165d2rBhgyTpqquuCmib0NzcXN1xxx36448/tHv3bo0dOzbgemqL/Px89enTR5MnT1b79u1ruhwAAACgUgjuAAAAAOAoeeONN1RYWKibbrrJs/ItGG63W4sXL1Zqaqo+++wzTZs2TU2aNAlqjso8t7S4uDh169bN57UdO3Zo+/btkqQePXqobt26Qc/vdrsrvUrv66+/1pdfful5/cwzz+iZZ54JePycOXMUHR2tLl26eFbbORwO3X333UHXsnHjRg0bNkxz585VeHh4uc9csmSJpk+frqZNm1Y47759+zRq1CgdOHBAY8eO9bma7qOPPvIcL126tEy/P3/cbrcn8Jw3b54OHjyoyZMny2g0+h0zYsQILV++vMK5S0RGRiomJkbJyclq27atLr74YnXo0CHg8eXJycnR/fffr3/++Sck8wEAAAA1heAOAAAAACopIyMjqF5mXbp00dVXX6133nlHkyZN0nnnnRfU89avX6/U1FRJxVtS9urVS9OmTVOPHj0CnsNsrr5/BpYOzW644Yagxx84cEC333677rjjDnXt2jWosQcPHtT48eMlSY0aNdJrr72mhg0bSpIefPBB7dixQ0888YRSUlIqnOuWW26R3W5Xhw4d9MILLygsLExFRUW69tpr1alTJ919992KjIwM+v35YrFYtGHDBl166aVBj502bZrCw8PVr1+/MueXLVsmSapbt64uueQSDRw4sMK55s+f7wn4zGaznE6nsrKyyt1m9MEHH9SwYcO0ceNGTZo0SU6nU1Jxb8OHHnrI8/mXpMLCQuXk5Ojvv//WDz/8oNdee00LFixQ8+bNNX78eF1wwQVBvXe3260DBw5oz549WrlypZYsWaI9e/YENQcAAABQGxHcAQAAAEAljRo1SmeddZaGDx8eUH+6pKQkPfHEExoyZIgGDBigAQMG6P7771dYWFhAzzty5VSfPn100UUXBVVzST8+l8sV1LhAfPjhh5KKg7OYmBi/W1T6YrfbNWbMGP3111+65557NHPmTHXv3j3g8VOmTNHevXvVsGFDLVy4sExo9Mgjj6h79+66+uqr9dJLL6lNmzZ+51m8eLFWr16tiy66SE8//bTn9yYsLExTp05V37599dlnn+nZZ59Vq1atAq7Pn5I/N507d9b9999fpo758+erfv36WrBggef8X3/95dnOs0+fPrrmmmvKzPfnn39q8+bNkqQnnnhCjz/+uFq0aFFuYJuenq7PP/9ckmQymfTaa6/p7LPPrrD2hg0bqmHDhjrttNO0ZMkSbdy4UZI0cOBAv38uO3XqpMGDBys1NVUPPPCAfvjhBw0ZMkT33nuvbrvttgqfuXTpUj300ENyuVxyu90V3g8AAAAcawjuAAAAAKCSHn30UfXu3VsrV67UE088EVCQ07FjR/Xt21dvv/22Xn31Vf3000+aO3duhSv3MjMz9cEHH3he9+/fXxMmTKhU3WazWTabzet8amqq6tWrF1AIeaStW7fq999/l1TcY61nz56Vqk0qDvHuu+8+NW/eXKecckqF97/99tt6//33Vb9+fS1cuFCNGjUqcz0qKkp33HGHHn30UQ0ePFhvvfWWWrRo4TXPpk2bNGXKFF1zzTWaNGmS17aiZ555pi6//HItW7ZMN9xwg15++WWdc845lX6fkjy97aK
2023-07-08 16:23:44 +08:00
"text/plain": [
"<Figure size 1920x1440 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2023-08-19 10:35:48 +08:00
"x_name = '采购策略P1'\n",
2023-08-22 21:04:34 +08:00
"y_choose = [0, 1, 2]\n",
"y_prop = pd.DataFrame({'y_name': ['系统恢复用时R1', '产业-企业边累计扰乱次数R2', '产业-企业边最大传导深度R3', '产业-企业边断裂总数R4'],\n",
" 'line_style': [(1, 0),(3, 1), (1,1), (3,2,1,2)],\n",
" 'palette': sns.color_palette(\"deep\")[0:4]})\n",
"df_x = df.loc[df['自变量'] == x_name, 'level':].set_index('level').stack(\n",
").reset_index().rename(columns={'level': '水平', 'level_1': '响应变量', 0: '均值'})\n",
"df_x = df_x.loc[df_x['响应变量'].isin(y_prop.loc[y_choose]['y_name'])]\n",
2023-07-08 16:23:44 +08:00
"sns.set_theme(style=\"whitegrid\", rc=config)\n",
2023-08-22 21:04:34 +08:00
"ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n",
" markers=['o'],\n",
" dashes=y_prop.loc[y_choose]['line_style'].to_list(),\n",
" palette=y_prop.loc[y_choose]['palette'].to_list(),\n",
" legend='brief')\n",
"ax.set_title(x_name)\n",
"for item in df_x.groupby('响应变量'):\n",
" for x, y, m in item[1][['水平', '均值', '均值']].values:\n",
" ax.text(x, y+0.05, f'{m:.2f}')"
2023-07-08 16:23:44 +08:00
]
},
{
"cell_type": "code",
2023-08-22 21:04:34 +08:00
"execution_count": 12,
2023-07-08 16:23:44 +08:00
"metadata": {},
"outputs": [
{
2023-08-22 21:04:34 +08:00
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\ASUS\\AppData\\Local\\Temp\\ipykernel_27216\\1224603408.py:10: UserWarning: \n",
"The markers list has fewer values (1) than needed (4) and will cycle, which may produce an uninterpretable plot.\n",
" ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n"
]
2023-07-08 16:23:44 +08:00
},
{
"data": {
2023-08-22 21:04:34 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABu4AAAViCAYAAADtEQplAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzdd3iTVR/G8TvdhQKlhUKh7GHZgmxFtlpUhryKyp6CgAgoiAoKgoiobAUZAoqiIg4EGSKCbFFk701ZpczSmSbvH7WxpUmblrQJ9Pu5Li6fJ3nOOb904EPunHMMZrPZLAAAAAAAAAAAAABO5ebsAgAAAAAAAAAAAAAQ3AEAAAAAAAAAAAAugeAOAAAAAAAAAAAAcAEEdwAAAAAAAAAAAIALILgDAAAAAAAAAAAAXADBHQAAAAAAAAAAAOACCO4AAAAAAAAAAAAAF0BwBwAAAAAAAAAAALgAgjsAAAAAAAAAAADABRDcAQAAAAAAAAAAAC6A4A4AAAAAAAAAAABwAQR3AAAAAAAAAAAAgAsguAMAAAAAAAAAAABcAMEdAAAAAAAAAAAA4AII7gAAAAAAAAAAAAAXQHAHAAAAAAAAAAAAuACCOwAAAAAAAAAAAMAFENwBAAAAAAAAAAAALoDgDgAAAAAAAAAAAHABBHcAAAAAAAAAAACACyC4AwAAAAAAAAAAAFw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gYGZHjuZyWTStWvXFBAQkKX2hQoVUoMGDbRx40b17Nn
2023-07-08 16:23:44 +08:00
"text/plain": [
"<Figure size 1920x1440 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2023-08-19 10:35:48 +08:00
"x_name = '最大尝试次数P3'\n",
2023-08-22 21:04:34 +08:00
"y_choose = [0, 1, 2, 3]\n",
"y_prop = pd.DataFrame({'y_name': ['系统恢复用时R1', '产业-企业边累计扰乱次数R2', '产业-企业边最大传导深度R3', '产业-企业边断裂总数R4'],\n",
" 'line_style': [(1, 0),(3, 1), (1,1), (3,2,1,2)],\n",
" 'palette': sns.color_palette(\"deep\")[0:4]})\n",
"df_x = df.loc[df['自变量'] == x_name, 'level':].set_index('level').stack(\n",
").reset_index().rename(columns={'level': '水平', 'level_1': '响应变量', 0: '均值'})\n",
"df_x = df_x.loc[df_x['响应变量'].isin(y_prop.loc[y_choose]['y_name'])]\n",
2023-07-08 16:23:44 +08:00
"sns.set_theme(style=\"whitegrid\", rc=config)\n",
2023-08-22 21:04:34 +08:00
"ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n",
" markers=['o'],\n",
" dashes=y_prop.loc[y_choose]['line_style'].to_list(),\n",
" palette=y_prop.loc[y_choose]['palette'].to_list(),\n",
" legend='brief')\n",
"ax.set_title(x_name)\n",
"for item in df_x.groupby('响应变量'):\n",
" for x, y, m in item[1][['水平', '均值', '均值']].values:\n",
" ax.text(x, y+0.05, f'{m:.2f}')"
2023-07-08 16:23:44 +08:00
]
},
{
"cell_type": "code",
2023-08-22 21:04:34 +08:00
"execution_count": 13,
2023-07-08 16:23:44 +08:00
"metadata": {},
"outputs": [
{
2023-08-22 21:04:34 +08:00
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\ASUS\\AppData\\Local\\Temp\\ipykernel_27216\\2665207915.py:10: UserWarning: \n",
"The markers list has fewer values (1) than needed (4) and will cycle, which may produce an uninterpretable plot.\n",
" ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n"
]
2023-07-08 16:23:44 +08:00
},
{
"data": {
2023-08-22 21:04:34 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABu4AAAViCAYAAADtEQplAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzde3zO9f/H8ee189iY2RyHhYTIIRT5Rk5lOZVCDuWQ87GcIjkmKXKKCIUO+KaSU6ISSTmUcpbz2YzZbDa2a9f1+2M/13eza9t1zXXtuvC4327fW5/Pdb0Pr89m6ns9936/DWaz2SwAAAAAAAAAAAAALuXh6gIAAAAAAAAAAAAAENwBAAAAAAAAAAAAboHgDgAAAAAAAAAAAHADBHcAAAAAAAAAAACAGyC4AwAAAAAAAAAAANwAwR0AAAAAAAAAAADgBgjuAAAAAAAAAAAAADdAcAcAAAAAAAAAAAC4AYI7AAAAAAAAAAAAwA0Q3AEAAAAAAAAAAABugOAOAAAAAAAAAAAAcAMEdwAAAAAAAAAAAIAbILgDAAAAAAAAAAAA3ADBHQAAAAAAAAAAAOAGCO4AAAAAAAAAAAAAN0BwBwAAAAAAAAAAALgBgjsAAAAAAAAAAADADRDcAQAAAAAAAAAAAG6A4A4AAAAAAAAAAABwAwR3AAAAAAAAAAAAgBsguAMAAAAAAAAAAADcAMEdAAAAAAAAAAAA4AYI7gAAAAAAAAAAAAA3QHAHAAAAAAAAAAAAuAGCOwAAAAAAAAAAAMANENwBAAAAAAAAAAAAboDgDgAAAAAAAAAAAHADBHcAAAAAAAAAAACAGyC4AwAAAADYJS4uztUlAAAAAMA9ieAOAAAAgEtFRUVp6tSpSkxMdFkNSUlJDhvr8OHDdzzGsWPHdOPGDQdU43gmk0kvvPCCXnvtNZ05c8bV5WTpwIED2r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HsiuAMAAACQK77++mvFx8dr1qxZmjVrVpZtx44dm+X7sbGx6t27txYtWqRy5cpZbXPmzBn5+PioRYsWOS3ZLhs2bLBcN2vWTHnz5s3xWM4K7m4FY3eyqi0zM2fO1MyZM+94nJyGdxs2bNCcOXNUsWJFzZkzJ9Pz6EJDQzVlyhS9/PLLat68uSZNmqQGDRpkaJddcLRq1SqNGjVKN2/elJS6svPVV19VuXLlnLbCa8mSJUpMTJSUGkD27t3bpn7e3t5q2rSpli1bpjVr1qhly5ZOqS+nli9froSEBElS5cqV9cwzzzhk3F9++UX9+/dXUlKSOnfurEWLFlkN70aMGKHevXtrz549GjdunGVFY3h4uEaOHKmiRYta2t64cUPXrl3T0aNHtWPHDn3++edatGiRypQpo9GjR2e7+tER/P39VbZsWafPAwAAANcguAMAAADgdFFRUZo9e7Ykadq0aYqIiLB7jMOHD6tly5YKCQnR6NGj9dRTT8nb29tq2+vXrys6OlpNmzZVUFBQluMajcZ055nlRHJysn755RfL/Ysvvphtn/j4+Fw/v87Pz0/z5s3TxIkTFRAQoIoVKyokJESBgYFOWSF2J3x9fW1uu3PnTg0dOlTh4eFasGBBtl/XmjVrqkOHDvrss8/Up08f9e/fX3379rVprmvXrmncuHFas2aNJKls2bLq2bOnmjVrZtMqvZy6evWqvvjiC8v9kCFDlD9/fpv7d+rUScuWLdPcuXPVvHlzh9Z67tw53bhxI8f9v/zyS8v1888/n+mKXHscPnxYw4cPV1JSkuX+lVde0eLFizOEd0WLFlXRokVVoUIFrVixQnv27JEkvfzyy6pXr57V8evWravOnTvr3LlzeuONN7Rjxw5
2023-07-08 16:23:44 +08:00
"text/plain": [
"<Figure size 1920x1440 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2023-08-19 10:35:48 +08:00
"x_name = '额外产能分布P5'\n",
2023-08-22 21:04:34 +08:00
"y_choose = [0, 1, 2, 3]\n",
"y_prop = pd.DataFrame({'y_name': ['系统恢复用时R1', '产业-企业边累计扰乱次数R2', '产业-企业边最大传导深度R3', '产业-企业边断裂总数R4'],\n",
" 'line_style': [(1, 0),(3, 1), (1,1), (3,2,1,2)],\n",
" 'palette': sns.color_palette(\"deep\")[0:4]})\n",
"df_x = df.loc[df['自变量'] == x_name, 'level':].set_index('level').stack(\n",
").reset_index().rename(columns={'level': '水平', 'level_1': '响应变量', 0: '均值'})\n",
"df_x = df_x.loc[df_x['响应变量'].isin(y_prop.loc[y_choose]['y_name'])]\n",
2023-07-08 16:23:44 +08:00
"sns.set_theme(style=\"whitegrid\", rc=config)\n",
2023-08-22 21:04:34 +08:00
"ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n",
" markers=['o'],\n",
" dashes=y_prop.loc[y_choose]['line_style'].to_list(),\n",
" palette=y_prop.loc[y_choose]['palette'].to_list(),\n",
" legend='brief')\n",
"ax.set_title(x_name)\n",
"for item in df_x.groupby('响应变量'):\n",
" for x, y, m in item[1][['水平', '均值', '均值']].values:\n",
" ax.text(x, y+0.05, f'{m:.2f}')"
2023-07-08 16:23:44 +08:00
]
},
{
"cell_type": "code",
2023-08-22 21:04:34 +08:00
"execution_count": 14,
2023-07-08 16:23:44 +08:00
"metadata": {},
"outputs": [
{
2023-08-22 21:04:34 +08:00
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\ASUS\\AppData\\Local\\Temp\\ipykernel_27216\\759130329.py:10: UserWarning: \n",
"The markers list has fewer values (1) than needed (4) and will cycle, which may produce an uninterpretable plot.\n",
" ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n"
]
2023-07-08 16:23:44 +08:00
},
{
"data": {
2023-08-22 21:04:34 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABtcAAAViCAYAAAB596OXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AA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OnD7Zs2QKVSoXp06ejXr16sLe31zmvX79+AIDbt2+jQoUKKFy4MJydneHk5ASRSCSct3v3bqxZswZAaqXVtGnTTFqHoZDCFJcuXdI6XrlyJSpVqmT2PBLJ+/8bMnbsWPzwww8ZXlNWsbKywoQJE9C1a1cAQFhYGBYvXmzy1/lDCoVC631nxv79+3H27FkAQOHChbFgwQKULFnSrDk011KwYEHMmzcv3WAtKSkJdnZ2GVuwmX799VcAqVVDixcvxuXLl7Fs2TK9vy958+aFp6cngoODYWVllS3ry6ijR48Kj/PkyYMtW7aYHUznhFu3bmHIkCF4+fIlAKBGjRqYPHkyChcubHDMmjVrkDdvXjRs2FCreszSAgICcODAAQwePBidO3fGhAkTtH62jf3Obd68WQip3759i0ePHmmFa5p/8woXLow+ffpY+B0QERER0aeK4RoRERERkYUEBwdDJBLBx8dH5zVPT0+UL18eV69eRVRUFM6dO4dGjRrpnKdSqYSALT2abckGDhyIIkWKZG7xJtBs01eqVKkMBWsAtEIQR0fHTK8rq1StWhUlSpTA/fv3AQDR0dEZmuf58+fo168fpkyZgpo1a2ZqTREREZg+fToAoFatWli8eDGcnJzMnkczdOjQoQMKFChg8NyrV69ixIgR2LBhA3x9fc2+ljlevnyJ06dPC8fFixdH//799QZraerVq4cdO3bg6dOnWsHIx+Ty5csIDQ0VjocMGfJJBGs7d+7E9OnTkZKSAg8PDwQGBqJVq1ZGx3l6emLy5MkICgqCn58fOnfubHYAbAqpVIqRI0dixIgR2LZtG169eoVly5YJf2M0K9c+FB0djd9++w0AUK1aNaxYsQIODg5a51y+fFl43K1bt48+wCUiIiKi7MM914iIiIiILGTx4sU4c+aMwde/+uorAICDgwPKlSun83poaChat24thDnpSasiKVy4MOrUqZPBFZsuMTERt27dEo47duyY4bk+pRvUmkFChw4dzB7//Plz+Pv749mzZxgwYADOnz+f4bWoVCqMGTMG0dHR+Oabb7By5UqdYO3hw4daFVKGmPo9ePLkCQYOHIhXr16hb9++6e5vZQnr168X9n+ztrbGsmXLUKNGjXTHpO2jpbkX2MdGc1+yQoUKoX379hab25y99kwVFRWFgIAATJw4EUqlEt27d8fhw4dNCtaA1N+bffv2oWzZstixYwfatGmDjh074tixYxZfb/PmzYVQ9cSJE9iyZYvwWno/5ytWrEB8fDyKFy+OZcuW6QRrwPvKNXt7e7Ru3dqi6yYiIiKiTxsr14iIiIiILCAhIQEnTpyAr68vHj9+rPcce3t7WFlZYcyYMYiPj0d8fLzwmlqtxujRo/Hw4UN069YNq1evRvny5Q1e79WrVwCATp06WfaNGHD27FnI5XIAqeGgqTfZ9dFsb/mxK1OmDABg6NChqF27tllj04K1169fAwCSk5MxYMAArFixIkMVbEuXLsW5c+dQvXp1LFu2TG8bRxcXF8yYMQO7d+/G1KlTkSdPHr1zmdIe9OrVqxgwYIBQsRccHIwBAwZg06ZNOvvmWUJUVBR27twpHHft2jXdiro01atXR65cubBnzx7079//owtvY2NjcfjwYeF4+PDhFlvjyZMnsWzZMqxcuRKurq6Znk+hUGD79u1YunQp3r59i5o1a2LChAkoVqyY2XN5e3tj/fr1WLVqFRYsWICrV68iICAAJUqUwPjx442
2023-07-08 16:23:44 +08:00
"text/plain": [
"<Figure size 1920x1440 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2023-08-19 10:35:48 +08:00
"x_name = '额外产能分布参数P6'\n",
2023-08-22 21:04:34 +08:00
"y_choose = [0, 1, 2, 3]\n",
"y_prop = pd.DataFrame({'y_name': ['系统恢复用时R1', '产业-企业边累计扰乱次数R2', '产业-企业边最大传导深度R3', '产业-企业边断裂总数R4'],\n",
" 'line_style': [(1, 0),(3, 1), (1,1), (3,2,1,2)],\n",
" 'palette': sns.color_palette(\"deep\")[0:4]})\n",
"df_x = df.loc[df['自变量'] == x_name, 'level':].set_index('level').stack(\n",
").reset_index().rename(columns={'level': '水平', 'level_1': '响应变量', 0: '均值'})\n",
"df_x = df_x.loc[df_x['响应变量'].isin(y_prop.loc[y_choose]['y_name'])]\n",
2023-07-08 16:23:44 +08:00
"sns.set_theme(style=\"whitegrid\", rc=config)\n",
2023-08-22 21:04:34 +08:00
"ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n",
" markers=['o'],\n",
" dashes=y_prop.loc[y_choose]['line_style'].to_list(),\n",
" palette=y_prop.loc[y_choose]['palette'].to_list(),\n",
" legend='brief')\n",
"ax.set_title(x_name)\n",
"for item in df_x.groupby('响应变量'):\n",
" for x, y, m in item[1][['水平', '均值', '均值']].values:\n",
" ax.text(x, y+0.05, f'{m:.2f}')"
2023-07-08 16:23:44 +08:00
]
},
{
"cell_type": "code",
2023-08-22 21:04:34 +08:00
"execution_count": 17,
2023-07-08 16:23:44 +08:00
"metadata": {},
"outputs": [
{
"data": {
2023-08-22 21:04:34 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABwUAAAVjCAYAAAAowfCGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzddXhTZxsG8Dtt2lL30gKFUqzA0CHDPhyG+2BIoWjR4TIYUpzhZTAcynDXMdzd3d2q1C1p8v3R9SwhSRurUO7fde3i5Mh73oS2o7nzPK9ILpfLQURERERERERERERERES5lkl2T4CIiIiIiIiIiIiIiIiIMhdDQSIiIiIiIiIiIiIiIqJcjqEgERERERERERERERERUS7HUJCIiIiIiIiIiIiIiIgol2MoSERERERERERERERERJTLMRQkIiIiIiIiIiIiIiIiyuUYChIRERERERERERERERHlcgwFiYiIiIiIiIiIiIiIiHI5hoJEREREREREREREREREuRxDQSIiIiIiIiIiIiIiIqJcjqEgERERERERERERERERUS7HUJCIiIiIiIiIiIiIiIgol2MoSERERERERERERERERJTLMRQkIiIiIiIiIiIiIiIiyuUYChIRERERERERERERERHlcgwFiYiIiIiIiIiIiIiIiHI5hoJEREREREREREREREREu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yfLj5+/IiFCxcCAG7duoU+ffqgfPny+O2335RaVWY1Xb7W1fnnn3+EbV9
2023-07-08 16:23:44 +08:00
"text/plain": [
"<Figure size 1920x1440 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2023-08-19 10:35:48 +08:00
"x_name = '新供应关系构成概率P7'\n",
2023-08-22 21:04:34 +08:00
"y_choose =[1]\n",
"y_prop = pd.DataFrame({'y_name': ['系统恢复用时R1', '产业-企业边累计扰乱次数R2', '产业-企业边最大传导深度R3', '产业-企业边断裂总数R4'],\n",
" 'line_style': [(1, 0),(3, 1), (1,1), (3,2,1,2)],\n",
" 'palette': sns.color_palette(\"deep\")[0:4]})\n",
"df_x = df.loc[df['自变量'] == x_name, 'level':].set_index('level').stack(\n",
").reset_index().rename(columns={'level': '水平', 'level_1': '响应变量', 0: '均值'})\n",
"df_x = df_x.loc[df_x['响应变量'].isin(y_prop.loc[y_choose]['y_name'])]\n",
2023-08-19 10:35:48 +08:00
"sns.set_theme(style=\"whitegrid\", rc=config)\n",
2023-08-22 21:04:34 +08:00
"ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n",
" markers=['o'],\n",
" dashes=y_prop.loc[y_choose]['line_style'].to_list(),\n",
" palette=y_prop.loc[y_choose]['palette'].to_list(),\n",
" legend='brief')\n",
"ax.set_title(x_name)\n",
"for item in df_x.groupby('响应变量'):\n",
" for x, y, m in item[1][['水平', '均值', '均值']].values:\n",
" ax.text(x, y+0.0005, f'{m:.2f}')"
2023-08-19 10:35:48 +08:00
]
},
{
"cell_type": "code",
2023-08-22 21:04:34 +08:00
"execution_count": 18,
2023-08-19 10:35:48 +08:00
"metadata": {},
"outputs": [
{
2023-08-22 21:04:34 +08:00
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\ASUS\\AppData\\Local\\Temp\\ipykernel_27216\\1838672856.py:10: UserWarning: \n",
"The markers list has fewer values (1) than needed (3) and will cycle, which may produce an uninterpretable plot.\n",
" ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n"
]
2023-08-19 10:35:48 +08:00
},
{
"data": {
2023-08-22 21:04:34 +08:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABtcAAAVjCAYAAACyq3AyAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzdd1hTZxsG8DshCRtZIigIah249657VKyr1j1wj7rqrrs46q6rtVZrxdGq1drWXWfdWz9xoVZEcSFDlozM7w9KTCCBJASCeP+uy6vnnJx3HESLufM+r0ClUqlARERERERERERERERERDkSWnoCRERERERERERERERERO8LhmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkRERERERERERERERGQghmtEREREREREREREREREBmK4RkREREREOZLJZJaeQqEkl8stPQWiAu3BgweWngIRERERURYM14iIiIiI3nOpqam4dOlSno7x7bffYtiwYYiOjs7TcQxx5MgRzJ49G48fP7b0VHJtzZo1mDFjBp48eWLpqeS5Xbt2IS4uztLTMKunT5/maf+XLl3C4cOH83SMgm7OnDno0qUL9u/fD4VCYenpEBEREREBYLhGRERERPTeU6lU6N+/P4YMGYJ79+6Zvf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oYPV8AiI+Px969e3HlyhWEhobizZs3SE5OhqOjIzw8PFCjRg20adMGjRo1Mql/IiIiIjIvhmtERERERIVAxhvQz549Q0BAQJ6No2vFUX57X/ZdGj16NC5dugQgPaA8fvw4OnfubHQ/ly5dwuHDhyEWi7FmzRqzB2sZOnTogMWLFyMlJQVyuRwrVqzAli1bzNa/ZuilK1wDgM8++wzr1q1DkSJF0KxZM4P6FYvFUCgU+Ouvv/DXX38Z1EYul2PBggUoX7486tSpY1AbXcwdrmUEWqGhoeqQbenSpShXrhxEIhFat26NHTt2qFewvW80g7T+/fujUqVKObbR/Bq3bNnSpHEPHToEADkGbNOmTcPIkSMREhKCoKAgdUlJPz8/TJ8+HV5eXup7U1NTkZCQgH///ReXL1/Gtm3bEBwcjDJlymD27NkG/zmVy+VYu3Ytfv75ZwDAp59+itGjR8PLywv29vaIj4/H/fv3cfDgQezYsQMVK1bEwoULUaFCBZO+FkRERERkHgzXiIiIiIgKgYzQq1SpUjh8+LBZ+3716hWaNm0KoGCsXHtfyrvVrVsXZcqUUa8klMvlRvchl8sxf/58CIVCLF261KAyiaZycHBAo0aNcOzYMQDapQfNQXPlmr69u2xsbLBu3TrY29tj06ZNGDhwYI6/35qBzZYtW7I
2023-08-19 10:35:48 +08:00
"text/plain": [
"<Figure size 1920x1440 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x_name = '最大尝试时间步P8'\n",
2023-08-22 21:04:34 +08:00
"y_choose=[0,1,2]\n",
"y_prop = pd.DataFrame({'y_name': ['系统恢复用时R1', '产业-企业边累计扰乱次数R2', '产业-企业边最大传导深度R3', '产业-企业边断裂总数R4'],\n",
" 'line_style': [(1, 0),(3, 1), (1,1), (3,2,1,2)],\n",
" 'palette': sns.color_palette(\"deep\")[0:4]})\n",
"df_x = df.loc[df['自变量'] == x_name, 'level':].set_index('level').stack(\n",
").reset_index().rename(columns={'level': '水平', 'level_1': '响应变量', 0: '均值'})\n",
"df_x = df_x.loc[df_x['响应变量'].isin(y_prop.loc[y_choose]['y_name'])]\n",
2023-07-08 16:23:44 +08:00
"sns.set_theme(style=\"whitegrid\", rc=config)\n",
2023-08-22 21:04:34 +08:00
"ax = sns.lineplot(data=df_x, x=\"水平\", y=\"均值\", hue=\"响应变量\", style=\"响应变量\",\n",
" markers=['o'],\n",
" dashes=y_prop.loc[y_choose]['line_style'].to_list(),\n",
" palette=y_prop.loc[y_choose]['palette'].to_list(),\n",
" legend='brief')\n",
"ax.set_title(x_name)\n",
"for item in df_x.groupby('响应变量'):\n",
" for x, y, m in item[1][['水平', '均值', '均值']].values:\n",
" ax.text(x, y+0.05, f'{m:.2f}')"
2023-07-08 16:23:44 +08:00
]
}
],
"metadata": {
"kernelspec": {
"display_name": "iiabm_py3.8.8",
"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.8.8"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}