In [1]:
print 0.00000000000000414285714285714


4.14285714286e-15

In [2]:
import numpy as np
import pandas as pd
import csv
import matplotlib as mpl
mpl.rcParams.update({'font.size': 11, 'font.family':'serif'})
from matplotlib.patches import Rectangle
import matplotlib.pyplot as plt
import seaborn as sns
#sns.set(style="whitegrid", color_codes=True)

In [13]:
import numpy as np
import pandas as pd
import csv
import matplotlib as mpl
mpl.rcParams.update({'font.size': 15, 'font.family':'serif'})
from matplotlib.patches import Rectangle
import matplotlib.pyplot as plt
from scipy.interpolate import UnivariateSpline
sns.set_style("white")

df = pd.read_csv('test_2.csv')
# df1 = pd.read_csv('del_shock.csv')

#Drag out columns
# x_del = np.array(df1['del_effect'])
# x_total= np.array(df1['total_effect'])
# x_total_negative = -1 * x_total
# y_2= np.array(df['shock'])

df = pd.read_csv('test_2.csv')
keys = np.unique(df['shock'])

print keys
for key in keys:
    if key == -0.1:
        I1 = np.argwhere(df['shock']==key).squeeze()
    if key == -0.2:
        I2 = np.argwhere(df['shock']==key).squeeze()
        

x1 = np.array(df['current_step'][I1])
x1new = np.linspace(0, len(x1), num=100)
x2 = np.array(df['current_step'][I2])
x2new = np.linspace(0, len(x1), num=100)

#For -10%
y1 = df['system_TAS'][I1] 
y2 = df['system_TAS'][I2] 
f1 = UnivariateSpline(x1, y1)
f2 = UnivariateSpline(x2, y2)

fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(15,6))

ax[0].plot(x1,y1,'o',  x1new,f1(x1new),'--', lw=2,  ms=4.5, color='r', label="-10%")
ax[0].plot(x2,y2,'bo',  x2new,f2(x2new),'--', lw=2,  ms=4.5, label="-20%")

# plt.plot(x1,y1,'o',  x1new,f1(x1new),'--', lw=1,  ms=3.5, color='r')
# plt.plot(x2,y2,'bo', x2new,f2(x2new),'--', lw=1,  ms=3.5)

ax[0].set_xlim(0, 7)
ax[0].set_xlabel("period", fontsize=15)
ax[0].set_ylim(-4e11, 0.1e11)
ax[0].set_ylabel("Asset sales", fontsize=15)
# ax[0].set_ylabel(r"Asset $\delta$ sales", fontsize=12)
ax[0].set_title("Asset sales in response to bond price shock", fontsize=15)
handles, labels = ax[0].get_legend_handles_labels()
p1 = Rectangle((0,0), 1, 1, fc="w")
handles.append(p1)
labels.append(r'RSA bond price shock')
ax[0].legend(handles, ['-10%', 'smoothed','-20%', 'smoothed', 'RSA bond price shock' ], fontsize=12, loc='best')

plt.show()

fig.savefig('sys_tas_sys_equity.eps', format='eps', dpi=1000)


plt.close()


[-0.2 -0.1]

In [436]:
plt.close()

In [437]:
plt.close()


df1 = pd.read_csv('del_shock.csv')
#Drag out columns
x_del = np.array(df1['del_effect'])
x_total= np.array(df1['total_effect'])
x_total_negative = -1 * x_total

y= np.array(df['shock'])

df = pd.read_csv('test_2.csv')
keys = np.unique(df['shock'])

fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(15,6))
for key in keys:
    I = np.argwhere(df['shock']==key).squeeze()

#print df['current_step'][I]

# nrows=2, ncols=2,
# ax[0,0] top left
# ax[0,1] top right
# ax[row, col]  

    #plt.figure('fig 1')
    ax[0].plot(df['current_step'][I], df['system_TAS'][I], label="system_TAS %s"%key)
    ax[1].plot()

ax[0].set_xlim(0, 7)
ax[0].set_xlabel("period", fontsize=12)
ax[0].set_ylim(-4e11, 0.1e11)
ax[0].set_ylabel(r"Asset $\delta$ sales", fontsize=12)
ax[0].set_title("My title is", fontsize=15)
handles, labels = ax[0].get_legend_handles_labels()
p1 = Rectangle((0,0), 1, 1, fc="w")
handles.append(p1)
ax[0].legend(['data', 'smoothened'], loc='best')
labels.append(r'x')
ax[0].legend(handles, labels)





plt.show()



In [148]:
plt.close()

In [ ]:


In [149]:
from scipy.interpolate import interp1d

x = np.linspace(0, 10, num=11, endpoint=True)
y = np.cos(-x**2/9.0)

f = interp1d(x, y)
f2 = interp1d(x, y, kind='cubic')
xnew = np.linspace(0, 10, num=41, endpoint=True)

import matplotlib.pyplot as plt
plt.plot(x, y, 'o', xnew, f(xnew), '-', xnew, f2(xnew), '--')
plt.legend(['data', 'linear', 'cubic'], loc='best')
plt.show()



In [1]:
import matplotlib.pyplot as plt
from scipy import interpolate
x = np.arange(0, 10)


y = np.exp(-x/3.0)
print x, y
f = interpolate.interp1d(x, y)

xnew = np.arange(0, 9, 0.1)
ynew = f(xnew)   # use interpolation function returned by `interp1d`
plt.plot(x, y, 'o', xnew, ynew, '-')
plt.show()


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-d6d48903630c> in <module>()
      1 import matplotlib.pyplot as plt
      2 from scipy import interpolate
----> 3 x = np.arange(0, 10)
      4 
      5 

NameError: name 'np' is not defined

In [13]:
import numpy as np
import pandas as pd
from scipy import stats, integrate
import matplotlib.pyplot as plt

import seaborn as sns
sns.set(color_codes=True)
df = pd.read_csv('del_shock.csv')
y = df['deleveraging'] 
x = y*100

x_filt = x[x<2]
# logx = np.log10(x)

nbins = 1000

n, bins = np.histogram(x_filt, nbins, density=1)
pdfx = np.zeros(n.size)
pdfy = np.zeros(n.size)
for k in range(n.size):
    pdfx[k] = 0.5*(bins[k]+bins[k+1])
    pdfy[k] = n[k]

plt.plot(pdfx, pdfy)
plt.show()

n, bins = np.histogram(x, nbins, density=1)
pdfx = np.zeros(n.size)
pdfy = np.zeros(n.size)

for k in range(n.size):
    pdfx[k] = 0.5*(bins[k]+bins[k+1])
    pdfy[k] = n[k]

plt.plot(pdfx, pdfy)
plt.show()

# sns.distplot(x);



In [36]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab



df = pd.read_csv('del_shock.csv')
x = df['deleveraging'] *100

#exclude extreme data
x_filt = x[x<1]

# Histogram:
# Bin it
n, bin_edges = np.histogram(x, 100)
# Normalize it, so that every bins value gives the probability of that bin
bin_probability = n/float(n.sum())
# Get the mid points of every bin
bin_middles = (bin_edges[1:]+bin_edges[:-1])/2.
# Compute the bin-width
bin_width = bin_edges[1]-bin_edges[0]
# Plot the histogram as a bar plot
plt.bar(bin_middles, bin_probability, width=bin_width)

plt.show()


# Histogram:
# Bin it
n, bin_edges = np.histogram(x_filt, 100)
# Normalize it, so that every bins value gives the probability of that bin
bin_probability = n/float(n.sum())
# Get the mid points of every bin
bin_middles = (bin_edges[1:]+bin_edges[:-1])/2.
# Compute the bin-width
bin_width = bin_edges[1]-bin_edges[0]
# Plot the histogram as a bar plot
plt.bar(bin_middles, bin_probability, width=bin_width)

plt.show()



In [443]:
#With seaborn 

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab


mpl.rcParams.update({'font.size': 11, 'font.family':'serif'})


df = pd.read_csv('del_shock.csv')
#Drag out columns
x_del = np.array(df['del_effect'])
x_total= np.array(df['total_effect'])
x_total_negative = -1 * x_total

y= np.array(df['shock'])

# #exclude extreme data
# x_filt = x[x<1]
# seaborn.distplot(x_filt, bins=100)

bar_width = 1 # default: 0.8

fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(7,7))
axes.barh(y, x_del, bar_width)
axes.barh(y, x_total_negative, bar_width)

axes.set_xlabel("% of total equity", fontsize=12)
axes.set_ylabel(r"RSA bond price decline in % of initial price", fontsize=12)
axes.set_title("Amplification of asset shocks, RSA Gov bonds", fontsize=15)

plt.legend(['Direct equity expose, %', 'Spillover equity exposure, %'], loc='best')

plt.show()
plt.close()


# plt.show()
# plt.close()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-443-73487ca05bf5> in <module>()
     24 fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(7,7))
     25 
---> 26 axes.barh(y, x_del, bar_width)
     27 axes.barh(y, x_total_negative, bar_width)
     28 

AttributeError: 'numpy.ndarray' object has no attribute 'barh'

In [344]:
import numpy as np
import pandas as pd
from scipy import stats, integrate
import matplotlib.pyplot as plt

import seaborn as sns
sns.set(color_codes=True)
df = pd.read_csv('del_shock.csv')
y = df['del_effect'] 
y_filt = y[y<2]

n, bins, patches = plt.hist(y, 100, normed=1, facecolor='g', alpha=0.75)
plt.show()



In [467]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab


mpl.rcParams.update({'font.size': 11, 'font.family':'serif'})


df = pd.read_csv('del_shock.csv')
#Drag out columns
x_del = np.array(df['del_effect'])
x_total= np.array(df['total_effect'])
x_total_negative = -1 * x_total

y= np.array(df['shock'])

# #exclude extreme data
# x_filt = x[x<1]
# seaborn.distplot(x_filt, bins=100)

bar_width = 1 # default: 0.8


plt.barh(y, x_del, bar_width)
plt.barh(y, x_total_negative, bar_width)

plt.xlabel("% of total equity", fontsize=12)
plt.ylabel(r"RSA bond price decline in % of initial price", fontsize=12)
plt.title("Amplification of asset shocks, RSA Gov bonds", fontsize=15)

plt.legend(['Direct equity expose, %', 'Spillover equity exposure, %'], loc='best')

plt.show()
plt.close()
# plt.legend(['data', 'linear'], loc='best')



In [471]:



---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-471-f11e7d38e89d> in <module>()
     23 bar_width = 1 # default: 0.8
     24 fig, ax = [1,1 ]
---> 25 ax.barh(y, x_del, bar_width)
     26 
     27 second = plt.barh(y, x_total_negative, bar_width)

AttributeError: 'int' object has no attribute 'barh'

In [555]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
mpl.rcParams.update({'font.size': 11, 'font.family':'serif'})
import seaborn as sbn

tas_bonds_10 = pd.read_csv('heat_bonds_10.csv')
result10 = tas_bonds_10 .pivot(index="bank",columns="period", values="TAS")

tas_50 = pd.read_csv('heat_bonds50.csv')
result50 = tas_50.pivot(index="bank_total_asset_sales",columns="period", values="TAS")

f,(ax1,ax2, axcb) = plt.subplots(1,3,   gridspec_kw={'width_ratios':[1,1,1,0.08] )
ax1.get_shared_y_axes().join(ax2,ax2)                                                     
                                                     
g1 = sns.heatmap(result10, cbar=False, ax=ax1,  vmin=-1e9, vmax=0)
g1.set_ylabel('')
g1.set_xlabel('')
g1.set_yticks([])

g2 = sns.heatmap(result50,ax=ax2,  vmin=-1e9, vmax=0)
g2.set_ylabel('')
g2.set_xlabel('')
g2.set_yticks([])
plt.show()


# ax=sns.heatmap(result10,  vmin=-1e9, vmax=0 )



# ax=sns.heatmap(result50,  vmin=-1e9, vmax=0 )



In [539]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
mpl.rcParams.update({'font.size': 11, 'font.family':'serif'})
tas_50 = pd.read_csv('heat_bonds50.csv')
import seaborn as sbn

# ax = sns.heatmap(dfh)
result = tas_50.pivot(index="bank_total_asset_sales",columns="period", values="TAS")

ax=sns.heatmap(result,  vmin=-1e9, vmax=0 )

plt.show()



In [538]:
plt.close()


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-538-c3b427156f1d> in <module>()
     11 # ax=sns.heatmap(result,  vmin=-1e9, vmax=0 )
     12 # Now if we normalize it by column:
---> 13 sns.clustermap(dfh, cmap='viridis')
     14 
     15 plt.show()

/anaconda/lib/python2.7/site-packages/seaborn/matrix.pyc in clustermap(data, pivot_kws, method, metric, z_score, standard_scale, figsize, cbar_kws, row_cluster, col_cluster, row_linkage, col_linkage, row_colors, col_colors, mask, **kwargs)
   1299                         row_cluster=row_cluster, col_cluster=col_cluster,
   1300                         row_linkage=row_linkage, col_linkage=col_linkage,
-> 1301                         **kwargs)

/anaconda/lib/python2.7/site-packages/seaborn/matrix.pyc in plot(self, metric, method, colorbar_kws, row_cluster, col_cluster, row_linkage, col_linkage, **kws)
   1129         colorbar_kws = {} if colorbar_kws is None else colorbar_kws
   1130         self.plot_dendrograms(row_cluster, col_cluster, metric, method,
-> 1131                               row_linkage=row_linkage, col_linkage=col_linkage)
   1132         try:
   1133             xind = self.dendrogram_col.reordered_ind

/anaconda/lib/python2.7/site-packages/seaborn/matrix.pyc in plot_dendrograms(self, row_cluster, col_cluster, metric, method, row_linkage, col_linkage)
   1022             self.dendrogram_row = dendrogram(
   1023                 self.data2d, metric=metric, method=method, label=False, axis=0,
-> 1024                 ax=self.ax_row_dendrogram, rotate=True, linkage=row_linkage)
   1025         else:
   1026             self.ax_row_dendrogram.set_xticks([])

/anaconda/lib/python2.7/site-packages/seaborn/matrix.pyc in dendrogram(data, linkage, axis, label, metric, method, rotate, ax)
    744     plotter = _DendrogramPlotter(data, linkage=linkage, axis=axis,
    745                                  metric=metric, method=method,
--> 746                                  label=label, rotate=rotate)
    747     if ax is None:
    748         ax = plt.gca()

/anaconda/lib/python2.7/site-packages/seaborn/matrix.pyc in __init__(self, data, linkage, metric, method, axis, label, rotate)
    562 
    563         if linkage is None:
--> 564             self.linkage = self.calculated_linkage
    565         else:
    566             self.linkage = linkage

/anaconda/lib/python2.7/site-packages/seaborn/matrix.pyc in calculated_linkage(self)
    626             return self._calculate_linkage_fastcluster()
    627         except ImportError:
--> 628             return self._calculate_linkage_scipy()
    629 
    630     def calculate_dendrogram(self):

/anaconda/lib/python2.7/site-packages/seaborn/matrix.pyc in _calculate_linkage_scipy(self)
    601                         '"pip install fastcluster")')
    602         linkage = hierarchy.linkage(self.array, method=self.method,
--> 603                                     metric=self.metric)
    604         return linkage
    605 

/anaconda/lib/python2.7/site-packages/scipy/cluster/hierarchy.pyc in linkage(y, method, metric)
    655         raise ValueError("Invalid method: {0}".format(method))
    656 
--> 657     y = _convert_to_double(np.asarray(y, order='c'))
    658 
    659     if y.ndim == 1:

/anaconda/lib/python2.7/site-packages/scipy/cluster/hierarchy.pyc in _convert_to_double(X)
   1107 def _convert_to_double(X):
   1108     if X.dtype != np.double:
-> 1109         X = X.astype(np.double)
   1110     if not X.flags.contiguous:
   1111         X = X.copy()

ValueError: could not convert string to float: SBSA

In [18]:
import seaborn  as sns
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib as mpl
mpl.rcParams.update({'font.size': 10, 'font.family':'serif'})

tas_bonds_10 = pd.read_csv('heat_bonds_10.csv')
result10 = tas_bonds_10.pivot(index="bank",columns="period", values="TAS")

tas_50 = pd.read_csv('heat_bonds50.csv')
result50 = tas_50.pivot(index="bank_total_asset_sales",columns="period", values="TAS")

fig,(ax1,ax2, axcb) = plt.subplots(1,3, figsize=(10,5),
            gridspec_kw={'width_ratios':[1,1,0.08]})
ax1.get_shared_y_axes().join(ax1,ax2)


g1 = sns.heatmap(result10, vmin=-1e9, vmax=0,cbar=False,ax=ax1)
g1.set_ylabel('')
g1.set_xlabel('Selling periods')
g1.set_title('Fire-sales occurrence, -10%  Gov bonds')
 
g3 = sns.heatmap(result50,vmin=-1e9, vmax=0,ax=ax2, cbar_ax=axcb)

# # may be needed to rotate the ticklabels correctly:
# for ax in [g1,g3]:
#     tl = ax.get_xticklabels()
#     ax.set_xticklabels(tl, rotation=90)
#     tly = ax.get_yticklabels()
#     ax.set_yticklabels(tly, rotation=0)

g3.set_ylabel('')
g3.set_xlabel('Selling periods')
g3.set_yticks([])
g3.set_title('Fire-sales occurrence, -50% Gov bonds')

plt.show()


fig.savefig('sys_heat1.eps', format='eps', dpi=1000)



In [19]:
import seaborn  as sns
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib as mpl
mpl.rcParams.update({'font.size': 10, 'font.family':'serif'})

cmap = sns.cubehelix_palette(50, hue=0.05, rot=0, light=0.9, dark=0, as_cmap=True)
cmap1 = sns.diverging_palette(10, 220, sep=80, n=7)

tas_bonds_10 = pd.read_csv('heat_bonds_10.csv')
result10 = tas_bonds_10.pivot(index="bank",columns="period", values="TAS")

equity_bonds_10 = pd.read_csv('equity_bond_10_norm.csv')
result_equity_bond_10 = equity_bonds_10.pivot("bank","period","equity")

equity_bonds_50 = pd.read_csv('equity_bond_50_norm.csv')

result_equity_bonds_50 = equity_bonds_50.pivot(index="bank",columns="period", values="equity")



fig2,(ax1,ax2, axcb) = plt.subplots(1,3, figsize=(10,5),
            gridspec_kw={'width_ratios':[1,1,0.08]})

ax1.get_shared_y_axes().join(ax1,ax2)

#for reverse: "YlGnBu_r"
# center=result_equity_bond_10.loc["ABSA", 4]
g3 = sns.heatmap(result_equity_bond_10, cmap=cmap1, vmin=0, vmax=1,cbar=False,ax=ax1)
g3.set_ylabel('')
g3.set_xlabel('Selling periods')
g3.set_title('% of pre-shock equity, -10%  Gov bonds')
 
g4 = sns.heatmap(result_equity_bonds_50,cmap=cmap1, vmin=0,  vmax=1,ax=ax2, cbar_ax=axcb)
g4.set_ylabel('')
g4.set_xlabel('Selling periods')
g4.set_yticks([])
g4.set_title('% of pre-shock equity, -50% Gov bonds')



# # may be needed to rotate the ticklabels correctly:
# for ax in [g1,g3]:
#     tl = ax.get_xticklabels()
#     ax.set_xticklabels(tl, rotation=90)
#     tly = ax.get_yticklabels()
#     ax.set_yticklabels(tly, rotation=0)

plt.show()

fig2.savefig('sys_heat2.eps', format='eps', dpi=1000)


plt.close()



In [47]:
"3x2 did not work :("

# import seaborn  as sns
# import matplotlib.pyplot as plt
# import pandas as pd
# import matplotlib as mpl
# mpl.rcParams.update({'font.size': 10, 'font.family':'serif'})

# cmap = sns.cubehelix_palette(50, hue=0.05, rot=0, light=0.9, dark=0, as_cmap=True)

# tas_50 = pd.read_csv('heat_bonds50.csv')
# result50 = tas_50.pivot(index="bank_total_asset_sales",columns="period", values="TAS")
# tas_bonds_10 = pd.read_csv('heat_bonds_10.csv')
# result10 = tas_bonds_10.pivot(index="bank",columns="period", values="TAS")

# equity_bonds_10 = pd.read_csv('equity_bond_10_norm.csv')
# result_equity_bond_10 = equity_bonds_10.pivot("bank","period","equity")
# equity_bonds_50 = pd.read_csv('equity_bond_50_norm.csv')
# result_equity_bonds_50 = equity_bonds_50.pivot(index="bank",columns="period", values="equity")



# f,(ax1,ax2, ax3,ax4, axcb2, axcb2) = plt.subplots(2,3, figsize=(10,5),
#             gridspec_kw={'width_ratios':[1,1, 0.08],'height_ratios':[1,1]})

# ax1.get_shared_y_axes().join(ax1,ax2)

# g1 = sns.heatmap(result10, vmin=-1e9, vmax=0,cbar=False,ax=ax1)
# g1.set_ylabel('')
# g1.set_xlabel('Selling periods')
# g1.set_title('Fire-sales occurrence, -10%  Gov bonds')
 
# g3 = sns.heatmap(result50,vmin=-1e9, vmax=0,ax=ax2, cbar_ax=axcb)
# g3.set_ylabel('')
# g3.set_xlabel('Selling periods')
# g3.set_yticks([])
# g3.set_title('Fire-sales occurrence, -50% Gov bonds')


ax3.get_shared_y_axes().join(ax3,ax4)

# center=result_equity_bond_10.loc["ABSA", 4]
g1 = sns.heatmap(result_equity_bond_10, cmap="YlGnBu_r", vmin=0, vmax=1,cbar=False,ax=ax3)
g1.set_ylabel('')
g1.set_xlabel('Selling periods')
g1.set_title('Remaining equity in%, -10%  Gov bonds')
 
g3 = sns.heatmap(result_equity_bonds_50,cmap="YlGnBu_r", vmin=0,  vmax=1,ax=ax4, cbar_ax=axcb2)
g3.set_ylabel('')
g3.set_xlabel('Selling periods')
g3.set_yticks([])
g3.set_title('Remaining equity in %, -50% Gov bonds')


# # may be needed to rotate the ticklabels correctly:
# for ax in [g1,g3]:
#     tl = ax.get_xticklabels()
#     ax.set_xticklabels(tl, rotation=90)
#     tly = ax.get_yticklabels()
#     ax.set_yticklabels(tly, rotation=0)

plt.close()


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-47-4d7bfc81eb86> in <module>()
     20 
     21 f,(ax1,ax2, ax3,ax4, axcb2, axcb2) = plt.subplots(2,3, figsize=(10,5),
---> 22             gridspec_kw={'width_ratios':[1,1, 0.08],'height_ratios':[1,1]})
     23 
     24 ax1.get_shared_y_axes().join(ax1,ax2)

ValueError: need more than 2 values to unpack

In [4]:
tas_bonds_10 = pd.read_csv('heat_10_7_1.csv')

result10 = tas_bonds_10.pivot(index="bank",columns="iteration", values="TAS")

tas_50 = pd.read_csv('heat_50_7_1.csv')
result50 = tas_50.pivot(index="bank",columns="iteration", values="TAS")

fig, (ax1,ax2, axcb) = plt.subplots(1,3, figsize=(10,5),
            gridspec_kw={'width_ratios':[1,1,0.08]})

ax1.get_shared_y_axes().join(ax1,ax2)
g1 = sns.heatmap(result10, vmin=-1e9, vmax=0,cbar=False,ax=ax1)
g1.set_ylabel('')
g1.set_xlabel('Iteration')
g1.set_title('Fire-sales occurrence, -10%  Gov bonds') 
g3 = sns.heatmap(result50, vmin=-1e9, vmax=0,ax=ax2, cbar_ax=axcb)
g3.set_ylabel('')
g3.set_xlabel('Iteration')
g3.set_yticks([])
g3.set_title('Fire-sales occurrence, -50% Gov bonds')

fig.savefig('/Users/Tina/Dropbox/phd/projects/dissertation/write_up/Chapters/Chapter2/figures/heat_asset1.pdf', format="pdf", bbox_inches='tight')


####################
tas_bonds_10 = pd.read_csv('heat_10_7_2.csv')
tas_bonds_10 
result10 = tas_bonds_10.pivot(index="bank",columns="iteration", values="TAS")
tas_50 = pd.read_csv('heat_50_7_2.csv')
result50 = tas_50.pivot(index="bank",columns="iteration", values="TAS")
fig, (ax1,ax2, axcb) = plt.subplots(1,3, figsize=(10,5),
            gridspec_kw={'width_ratios':[1,1,0.08]})
ax1.get_shared_y_axes().join(ax1,ax2)

g1 = sns.heatmap(result10, vmin=-1e9, vmax=0,cbar=False,ax=ax1)

g1.set_ylabel('')
g1.set_xlabel('Iteration')
g1.set_title('Fire-sales occurrence, -10%  Gov bonds') 
g3 = sns.heatmap(result50, vmin=-1e9, vmax=0,ax=ax2, cbar_ax=axcb)

g3.set_ylabel('')
g3.set_xlabel('Iteration')
g3.set_yticks([])
g3.set_title('Fire-sales occurrence, -50% Gov bonds')

fig.savefig('/Users/Tina/Dropbox/phd/projects/dissertation/write_up/Chapters/Chapter2/figures/heat_asset2.pdf', format="pdf", bbox_inches='tight')

plt.show()



In [ ]: