Skip to content

Commit

Permalink
.plot.xxxx()
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-haru committed Aug 19, 2024
1 parent 62c66c8 commit 018fc93
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 111 deletions.
43 changes: 19 additions & 24 deletions 11_Macro_Variables.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
{
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
"heading_collapsed": true
},
"source": [
"## はじめに"
Expand Down Expand Up @@ -502,13 +501,11 @@
},
"outputs": [],
"source": [
"ax_ = df.plot(x='u_rate_cycle',\n",
" y='gdp_cycle',\n",
" kind='scatter')\n",
"ax_ = df.plot.scatter(x='u_rate_cycle',\n",
" y='gdp_cycle')\n",
"\n",
"df.plot(x='u_rate_cycle',\n",
" y='fitted_okun',\n",
" kind='line',\n",
" color='red',\n",
" ax=ax_)\n",
"pass"
Expand Down Expand Up @@ -542,7 +539,8 @@
{
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## フィリップス曲線"
Expand Down Expand Up @@ -711,7 +709,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### フラット化するフィリップス曲線"
Expand All @@ -734,7 +733,7 @@
},
"outputs": [],
"source": [
"df.plot(x='unemployment_rate', y='inflation', kind='scatter')\n",
"df.plot.scatter(x='unemployment_rate', y='inflation')\n",
"pass"
]
},
Expand Down Expand Up @@ -909,13 +908,12 @@
" \n",
" cond = ( df['decade']==d )\n",
" \n",
" df.loc[cond,:].plot(x='unemployment_rate',\n",
" y='inflation',\n",
" kind='scatter',\n",
" edgecolor=c, #3\n",
" color='white', #4\n",
" legend=False,\n",
" ax=ax)\n",
" df.loc[cond,:].plot.scatter(x='unemployment_rate',\n",
" y='inflation',\n",
" edgecolor=c, #3\n",
" color='white', #4\n",
" legend=False,\n",
" ax=ax)\n",
"\n",
" df.loc[cond,:].sort_values(f'{d}年代データ').plot(\n",
" x='unemployment_rate',\n",
Expand Down Expand Up @@ -988,18 +986,15 @@
},
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"metadata": {},
"source": [
"## インフレ率とマネーストックの増加率"
]
},
{
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
"heading_collapsed": true
},
"source": [
"### 説明"
Expand Down Expand Up @@ -1539,7 +1534,7 @@
" res = smf.ols('inflation ~ money_growth', data=df).fit() #2\n",
" df['トレンド'] = res.fittedvalues #3\n",
" \n",
" ax_ = df.plot(x='money_growth', y='inflation', kind='scatter') #4\n",
" ax_ = df.plot.scatter(x='money_growth', y='inflation') #4\n",
" df.sort_values('トレンド').plot(x='money_growth', y='トレンド', #5\n",
" color='r', ax=ax_) #6\n",
" ax_.set_title(f'{t}\\n' #7\n",
Expand Down Expand Up @@ -2107,7 +2102,7 @@
},
"outputs": [],
"source": [
"world.plot(x='money_growth', y='inflation', kind='scatter')\n",
"world.plot.scatter(x='money_growth', y='inflation')\n",
"pass"
]
},
Expand Down Expand Up @@ -2318,7 +2313,7 @@
},
"outputs": [],
"source": [
"ax_ = world_mean.plot(x='money_growth_mean', y='inflation_mean', kind='scatter')\n",
"ax_ = world_mean.plot.scatter(x='money_growth_mean', y='inflation_mean')\n",
"xpoints = ypoints = ax_.get_ylim()\n",
"ax_.plot(xpoints,ypoints,'r-', label='45度線')\n",
"ax_.set_title('平均インフレ率とマネーストトックの平均成長率', size='15')\n",
Expand Down
12 changes: 8 additions & 4 deletions 12_IS-MP-PC.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true,
"tags": [
"remove-cell"
]
Expand Down Expand Up @@ -227,7 +228,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### モデルの解"
Expand Down Expand Up @@ -405,7 +407,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### シミュレーション:インパルス反応"
Expand Down Expand Up @@ -532,7 +535,8 @@
{
"cell_type": "markdown",
"metadata": {
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"#### フィリップス曲線のショック"
Expand Down Expand Up @@ -1791,7 +1795,7 @@
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"## IS-MP-PSモデルの問題点"
"## IS-MP-PCモデルの問題点"
]
},
{
Expand Down
19 changes: 12 additions & 7 deletions 13_random_TFP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
},
"outputs": [],
"source": [
"dfwn.plot(kind='hist', bins=30)\n",
"dfwn.plot.hist(bins=30)\n",
"pass"
]
},
Expand Down Expand Up @@ -333,7 +333,7 @@
},
"outputs": [],
"source": [
"dfwn.plot(x='WNlag', y='WN', kind='scatter')\n",
"dfwn.plot.scatter(x='WNlag', y='WN')\n",
"pass"
]
},
Expand Down Expand Up @@ -1267,7 +1267,7 @@
},
"outputs": [],
"source": [
"df.plot(x='tfp_cycle_lag', y='tfp_cycle', kind='scatter')\n",
"df.plot.scatter(x='tfp_cycle_lag', y='tfp_cycle')\n",
"pass"
]
},
Expand Down Expand Up @@ -1437,7 +1437,9 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 初期値の計算"
]
Expand Down Expand Up @@ -1671,7 +1673,8 @@
{
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### シミュレーション"
Expand All @@ -1681,7 +1684,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"#### 関数"
Expand Down Expand Up @@ -1802,7 +1806,8 @@
"cell_type": "markdown",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"#### 実行"
Expand Down
35 changes: 17 additions & 18 deletions 19_PPP.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@
},
"outputs": [],
"source": [
"choco.plot(y='mean_deviation', kind='hist', bins=12, ec='white')\n",
"choco.plot.hist(y='mean_deviation', bins=12, ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -680,7 +680,7 @@
"source": [
"ice['mean_deviation'] = ice['price'] / ice['price'].mean() - 1\n",
"\n",
"ice.plot(y='mean_deviation', kind='hist', bins=16, ec='white')\n",
"ice.plot.hist(y='mean_deviation', bins=16, ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -939,7 +939,7 @@
"source": [
"gas['mean_deviation'] = gas['price'] / gas['price'].mean() - 1\n",
"\n",
"gas.plot(y='mean_deviation', kind='hist', ec='white')\n",
"gas.plot.hist(y='mean_deviation', ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -1052,7 +1052,6 @@
"id": "cc3f4f60",
"metadata": {
"heading_collapsed": true,
"jp-MarkdownHeadingCollapsed": true,
"tags": [
"remove-cell"
]
Expand Down Expand Up @@ -1229,7 +1228,8 @@
"id": "c5a9085a",
"metadata": {
"heading_collapsed": true,
"hidden": true
"hidden": true,
"jp-MarkdownHeadingCollapsed": true
},
"source": [
"### 一物一価"
Expand Down Expand Up @@ -1535,7 +1535,7 @@
},
"outputs": [],
"source": [
"bigmac.plot(y='price_yen_deviation', kind='hist', ec='white')\n",
"bigmac.plot.hist(y='price_yen_deviation', ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -1806,7 +1806,7 @@
},
"outputs": [],
"source": [
"ax = bigmac.plot(x='gdppc_yen', y='price_yen', kind='scatter', logx=True)\n",
"ax = bigmac.plot.scatter(x='gdppc_yen', y='price_yen', logx=True)\n",
"ax.set_xlabel('一人当たり実質GDP(円,常用対数)', fontsize=15)\n",
"ax.set_ylabel('Big Mac価格(円)', fontsize=15)\n",
"pass"
Expand Down Expand Up @@ -2397,7 +2397,7 @@
"source": [
"pwt19['pl_gdpo_log'] = np.log( pwt19['pl_gdpo'] )\n",
"\n",
"pwt19.plot(y='pl_gdpo_log', kind='hist', ec='white')\n",
"pwt19.plot.hist(y='pl_gdpo_log', ec='white')\n",
"pass"
]
},
Expand Down Expand Up @@ -2729,7 +2729,7 @@
},
"outputs": [],
"source": [
"ax = pwt19.plot(x='cgdpo_pc_log', y='pl_gdpo_log', kind='scatter')\n",
"ax = pwt19.plot.scatter(x='cgdpo_pc_log', y='pl_gdpo_log')\n",
"ax.set_xlabel('一人当たりGDP(対数,百万米ドル)', fontsize=15)\n",
"ax.set_ylabel('米国の2017年価格を基準とした\\n2019年相対価格(対数)', fontsize=15)\n",
"pass"
Expand Down Expand Up @@ -3012,7 +3012,7 @@
"outputs": [],
"source": [
"# 散布図\n",
"ax = pwt19.plot(x='cgdpo_pc_ratio_log', y='pl_gdpo_log', kind='scatter')\n",
"ax = pwt19.plot.scatter(x='cgdpo_pc_ratio_log', y='pl_gdpo_log')\n",
"ax.set_xlabel('米国を基準とした一人当たりGDP(対数,2019年)', fontsize=15)\n",
"ax.set_ylabel('米国の2017年価格を基準とした\\n2019年相対価格(対数)', fontsize=15)\n",
"\n",
Expand Down Expand Up @@ -3098,12 +3098,11 @@
"col_lst = ['pl_gdpo_log','income_effect','other_effect']\n",
"title_lst = ['相対価格(対数)','所得効果(対数)','その他の効果(対数)']\n",
"\n",
"ax = pwt19[col_lst].plot(kind='hist',\n",
" bins=20,\n",
" ec='white',\n",
" subplots=True,\n",
" legend=False,\n",
" figsize=(6,10))\n",
"ax = pwt19[col_lst].plot.hist(bins=20,\n",
" ec='white',\n",
" subplots=True,\n",
" legend=False,\n",
" figsize=(6,10))\n",
"\n",
"for i, s in enumerate(title_lst):\n",
" ax[i].set_title(s, fontsize=18)\n",
Expand Down Expand Up @@ -3603,7 +3602,7 @@
},
"outputs": [],
"source": [
"ax = pwt19.plot(x='cgdpo_pc_log', y='cgdpo_pc_xr_log', kind='scatter')\n",
"ax = pwt19.plot.scatter(x='cgdpo_pc_log', y='cgdpo_pc_xr_log')\n",
"ax.axline((9, 9), (10, 10), color='red', label='45度線') #1\n",
"ax.set_xlabel('一人当たりGDP(PPPレート)', fontsize=13)\n",
"ax.set_ylabel('一人当たりGDP(市場為替レート)', fontsize=13)\n",
Expand Down Expand Up @@ -3653,7 +3652,7 @@
},
"outputs": [],
"source": [
"ax = pwt19.plot(y=['cgdpo_pc_log','cgdpo_pc_xr_log'], kind='kde')\n",
"ax = pwt19.plot.kde(y=['cgdpo_pc_log','cgdpo_pc_xr_log'])\n",
"ax.legend(['PPPレート','市場為替レート'], fontsize=13)\n",
"ax.set_title('一人当たりGDP(米ドル,対数)', fontsize=20)\n",
"pass"
Expand Down
Loading

0 comments on commit 018fc93

Please sign in to comment.