I have a python plot and then would like to have a set of statistics in a table in a subplot adjacent to it. I have used kind of an adhoc approach in which I create a subplot with white axis colors and then make a table in the subplot. You can see that the table has white lines running through it if you look closely. My code is below.
import pandas as pd
import numpy as np
import datetime as dt
import matplotlib.pyplot
from patsy import dmatrices
import statsmodels.api as sm
import matplotlib.gridspec as gridspec
gs = gridspec.GridSpec(1, 2,width_ratios=[6,1])
ax1 = plt.subplot(gs[0])
plt.plot_date(sp_df.index,np.log(sp_df['PX_LAST']),'k')
sells = sp_df[(sp_df['hurst'] > 0.5) & (sp_df['sharpe'] < 0.5) & (sp_df['20dma'] < sp_df['65dma'])].index
buys = sp_df[(sp_df['hurst'] > 0.5) & (sp_df['sharpe'] > 0.5) & (sp_df['20dma'] > sp_df['65dma']) & (sp_df['50dma'] > sp_df['200dma'])].index
plt.plot_date(buys,np.log(sp_df.ix[buys]['PX_LAST']),'g^')
plt.plot_date(sells,np.log(sp_df.ix[sells]['PX_LAST']),'rv')
plt.xlim(sp_df.index[0] - dt.timedelta(days=90),sp_df.index[-1] + dt.timedelta(days=90))
ax2 = plt.subplot(gs[1])
total_return = 2.50
annualized_return = 1.257
sharpe_ratio = .85
max_dd = .12
dd_duration = 300
stats = {"Total Return" : "%0.2f%%" % ((total_return - 1.0) * 100.0),
"Annualized Return" : "%0.2f%%" %((annualized_return - 1.0) * 100.0),
"Sharpe Ratio" : "%0.2f" % sharpe_ratio,
"Max Drawdown" : "%0.2f%%" % (max_dd * 100.0),
"Drawdown Duration" : str(dd_duration) + " days"}
bbox=[0.0,0.0,.5, .5]
stats = pd.DataFrame(stats,index=range(1)).T
plt.table(cellText = stats.get_values(),colWidths=[0.6]*2,rowLabels=stats.index,colLabels=['Metrics'],loc='right')
plt.tick_params(axis='both',top='off',left='off',labelleft='off',right='off',bottom='off',labelbottom='off')
ax = plt.gca()
ax.spines['bottom'].set_color('white')
ax.spines['top'].set_color('white')
ax.spines['left'].set_color('white')
ax.spines['right'].set_color('white')
fig = plt.gcf()
fig.set_size_inches(11.5,8.5)
Along with a picture