filename = lambda ru: os.path.join(basedir,'all-results-0-%s-%s.pkl'%(ru[0],ru[1]))
data = {'%s-%s'%(r,u):cPickle.load(open(filename((r,u)),'rb')) for r in r_schema for u in u_schema}

formats = dict(zip(u_schema,['k','k--','k-.']))
sn = lambda alpha: (1-alpha)/alpha if alpha > 0 else 0

mixing_fractions = np.linspace(0,1,num=11)

accuracies = {}

fig,axs = plt.subplots(ncols=len(r_schema))
for reward,panel in zip(r_schema,axs):
	for stimulus in u_schema:

		accuracy = postdoc.accuracy_figure(data['%s-%s'%(reward,stimulus)],savename=None)
		panel.plot(artist.smooth(accuracy,beta=2),formats[stimulus],linewidth=2,label=artist.format(stimulus.capitalize()))

		accuracies['%s-%s'%(reward,stimulus)] = accuracy

		artist.adjust_spines(panel)

		panel.set_xlabel(r'\Large $\mathrm{\frac{Signal}{Noise}}$')
		panel.set_ylabel(r'\Large \textbf{%s, } $\mathrm{Accuracy, q\left(\mathbf{v}\right)\Bigg|_{\mathbf{v^0}}} $'%reward.capitalize())	

		panel.set_ylim((-1,1))
		xlabs = [r'\Large $\mathbf{%.02f}$'%alpha for alpha in map(sn,mixing_fractions[:-1])]
		xlabs[0] = r'\Large $\mathrm{All \; signal}$'
		xlabs[-1] = r'\Large $\mathrm{All \; noise}$'

		panel.set_xticklabels(xlabs, rotation='vertical')
plt.legend(frameon=False)
'''

basedir = '/Volumes/My Book/synchrony-data/2013-12-29-13-26-12'

r_schema = ['susceptible','resilient']
u_schema = ['exposure','chronic','cessation']

filename = lambda ru: os.path.join(basedir,'all-results-0-%s-%s.pkl'%(ru[0],ru[1]))
data = {'%s-%s'%(r,u):cPickle.load(open(filename((r,u)),'rb')) for r in r_schema for u in u_schema}

formats = dict(zip(u_schema,['k','k--','k-.']))

fig,axs = plt.subplots(nrows=1,ncols=2,sharex=True,sharey=True)
for reward,ax in zip(r_schema,axs):
	for stimulus in u_schema:
		ax.plot(artist.smooth(data['%s-%s'%(reward,stimulus)]['network_stability']),formats[stimulus],
			linewidth=2,label=artist.format(stimulus.capitalize()))
		plt.hold(True)

	ax.annotate(artist.format(reward.capitalize()), xy=(.2, .7),  xycoords='axes fraction',
    	horizontalalignment='center', verticalalignment='center')

	artist.adjust_spines(ax)
	ax.set_xlabel(artist.format('Time'))
	ax.set_ylabel(r'\Large $E\left(\mathbf{v}\right)$')



plt.legend(frameon=False)
plt.tight_layout()
plt.show()