# formatting the plot ax.xaxis.set_minor_locator(pylab.MultipleLocator(5)) ax.yaxis.set_minor_locator(pylab.MultipleLocator(0.1)) ax.grid(b=True,which="minor",axis='x') ax.grid(b=True,which="minor",axis='y') ax.set_xticks(range(1850,2030,10)) ax.set_xlim(1843,2021) ax.set_ylim(-1.03,0.89) ax.set_xlabel("Year") legend = ax.legend(loc="upper left",fontsize=14) frame = legend.get_frame() frame.set_facecolor('1.0') ax.set_ylabel("Anomaly") # adding an inset axis to view the downturn at the end better inset_axes = zoomed_inset_axes(ax, 3, loc=4) inset_axes.scatter(df2.Date,df2.Anomaly,s=15,marker='o',facecolor="1.0",lw=0.5,edgecolor="0.0") inset_axes.plot(df2.Date[s12:-e12],yr1LP2,'-y',label='Annual LP') inset_axes.plot(df2.Date[s152:-e152],yr15LP2,'-g',label='>15 yr LP') inset_axes.plot(df2.Date[s752:-e752],yr75LP2,'-b',label='>30 yr LP') inset_axes.plot(df2.Date,yr15SG2,'--r',label='S-G 15 yr') x1, x2, y1, y2 = 2000, 2015, 0.3, 0.6 inset_axes.set_xlim(x1, x2) inset_axes.set_ylim(y1, y2) inset_axes.set_xticks([]) inset_axes.set_yticks([]) inset_axes.set_axis_bgcolor("1.0") ax.set_title("HadCrut4 Monthly Anomaly Smoothing by CTRM and Savitsky-Golay") mark_inset(ax, inset_axes, loc1=1, loc2=2, fc="none", ec="0.0"); pylab.show()
#meter that I can replace in the above code that will allow custom locations of the inset axes within the parent axes? I've tried to use the bbox_to_ancax1.set_yscale('log') #ax1.set_ylim(0.55, 0.8) ax1.legend(['loss', 'val_loss'], loc=2) ax1.spines['top'].set_visible(False) ax1.spines['right'].set_visible(False) loss_20 = loss[-20:] val_loss_20 = val_loss[-20:] inset_axes = inset_axes( ax1, width="40%", # width = 30% of parent_bbox height="40%", # height : 1 inch loc=1) inset_axes.plot(loss_20, color='y') inset_axes.plot(val_loss_20, color='c') inset_axes.set_xlabel('Last 20 Epochs') inset_axes.set_ylabel('Loss') inset_axes.spines['top'].set_visible(False) inset_axes.spines['right'].set_visible(False) inset_axes.spines['bottom'].set_visible(False) inset_axes.get_xaxis().set_ticks([]) #inset_axes.spines['right'].set_visible(False) #inset_axes.set_yscale('log') #ax1.set_ylim(0.55, 0.8) #inset_axes.legend(['loss', 'val_loss']) ax2.hist(y_pred_test_even, 25, density=1,
plt.gca().set_color_cycle([colormap(i) for i in np.linspace(0, 0.9,len_index_alp)]) for i in list_index_alp: fg2.plot(rates,myprobs_pres_nov[i],lw=12,ls='--',alpha=0.8) fg2.set_xlim([0.01,30]) fg2.set_ylim([0,0.3]) fg2.set_yticks([0,0.1,0.2,0.3]) #fg2.set_xticks([0,0.1,0.2,0.3,0.4,0.5]) fg2.set_xlabel(r'Rate (Hz)',fontsize=45) fg2.set_ylabel(r'Dist. Rates',fontsize=45) fg2.tick_params(labelsize=35) fg2.set_title('(A)',fontsize=50,fontweight="bold",y=1.06) fg2.legend(loc=(0.01,0.47),numpoints=1,prop={'size':12}) inset_axes = inset_axes(fg2,width=5, height=3,loc=1,bbox_to_anchor=(0.345, 0.885),bbox_transform=fg2.figure.transFigure) colormap = plt.cm.Accent plt.gca().set_color_cycle([colormap(i) for i in np.linspace(0, 0.9,len_index_alp)]) for i in list_index_alp: inset_axes.plot(rates,myprobs_pres_fam[i],lw=8,alpha=0.8) colormap = plt.cm.Accent plt.gca().set_color_cycle([colormap(i) for i in np.linspace(0, 0.9,len_index_alp)]) for i in list_index_alp: inset_axes.plot(rates,myprobs_pres_nov[i],lw=8,ls='--',alpha=0.8) inset_axes.set_xlim([25,100]) inset_axes.set_ylim([0,0.02]) inset_axes.set_xticks([25.,75,100]) inset_axes.set_yticks([0.02]) inset_axes.tick_params(labelsize=30) inset_axes.set_xlabel(r'Rate (Hz)',fontsize=30) plt.savefig('figA.pdf', bbox_inches='tight')
fg7.set_xlim([12,37]) fg7.set_ylim([0.45,1.]) fg7.set_yticks([0.5,0.75,1.]) fg7.set_xticks([15,20,25,30,35]) fg7.tick_params(axis='both', which='major', labelsize=30) fg7.set_xlabel(r'Threshold ($x_f$)',fontsize=50) fg7.set_ylabel(r'Proportion Pot./Dep. ($q_f$)',fontsize=50) #fg7.axhline(y=.7, xmin=0, xmax=100, linewidth=10, color = 'b',alpha=0.5, linestyle='dashed') # Make a colorbar for the ContourSet returned by the contourf call. fg7.axvline(x=model_step.mean_patterns, ymin=0, ymax=1, linewidth=10, color = 'g',alpha=0.5, linestyle='dashed') fg7.axvline(x=model_step.median_patterns, ymin=0, ymax=1, linewidth=10, color = 'peru',alpha=0.5, linestyle='dashed') fg7.scatter(themaxcap[2][5:-1],themaxcap[3][5:-1],s=1000*(np.array(themaxcap[1][5:-1])/max(themaxcap[1])),alpha=0.5,color='b') fg7.set_title('(F)',fontsize=50,fontweight="bold",y=1.06) fg7.text(16,0.95,'Potentiation',fontsize=50) fg7.text(28,0.8,'Depresion',fontsize=50) inset_axes = inset_axes(fg7,width=5, height=3,loc=1,bbox_to_anchor=(0.895, 0.265),bbox_transform=fg7.figure.transFigure) inset_axes.plot(themaxcap[0][5:-1],themaxcap[1][5:-1],lw=8,color='maroon',alpha=0.8) inset_axes.set_xlim([0.5,7]) inset_axes.set_ylim([0.4,0.8]) #inset_axes.set_xticks([25.,75,100]) inset_axes.set_yticks([0.4,0.6,0.8]) inset_axes.tick_params(labelsize=30) inset_axes.set_xlabel(r'A',fontsize=30) inset_axes.set_ylabel(r'Larg.Max.Cap.($\alpha_c$)',fontsize=30) #cbar.set_ticklabels([0.08,0.32,0.64]) plt.savefig('fig3.pdf', bbox_inches='tight') print themaxcap[0][5] #plt.show()
for i in range(len(myprobs_fam)): fg2.plot(rates,myprobs_fam[i],lw=12,color=colors[i],alpha=0.8,label=r'$q_f=$'+str(theqf[i])) for i in range(len(myprobs_fam)): fg2.plot(rates,myprobs_nov[i],lw=12,color=colors[i],ls='--',alpha=0.8) fg2.set_xlim([0.01,25]) fg2.set_ylim([0,0.3]) #fg2.set_yticks([0,0.02,0.04]) #fg2.set_xticks([0,0.1,0.2,0.3,0.4,0.5]) fg2.set_xlabel(r'Rate (Hz)',fontsize=45) fg2.set_ylabel(r'Dist. Rates',fontsize=45) fg2.tick_params(labelsize=35) fg2.set_title('(E)',fontsize=50,fontweight="bold",y=1.06) fg2.legend(loc=(0.71,0.18),numpoints=1,prop={'size':30}) inset_axes = inset_axes(fg2,width=5, height=3,loc=1,bbox_to_anchor=(0.61, 0.423),bbox_transform=fg2.figure.transFigure) for i in range(len(myprobs_fam)): inset_axes.plot(rates,myprobs_fam[i],lw=8,alpha=0.8,color=colors[i],label=r'$q_f=$'+str(theqf[i])) for i in range(len(myprobs_nov)): inset_axes.plot(rates,myprobs_nov[i],lw=8,alpha=0.8,color=colors[i],ls='--',label=r'$q_f=$'+str(theqf[i])) inset_axes.set_xlim([25,100]) inset_axes.set_ylim([0,0.02]) inset_axes.set_xticks([25.,50,75,100]) inset_axes.set_yticks([0.02]) inset_axes.tick_params(labelsize=30) inset_axes.set_xlabel(r'Rate (Hz)',fontsize=30) inset_axes.set_ylabel(r'Dist. Rates',fontsize=30) plt.savefig('fig2.pdf', bbox_inches='tight')
for i in [index]: fg1.plot(rates,myprobs_delay_fam[i],lw=12,color=colors[2],alpha=0.8,label=r'Delay Familiar') for i in [index]: fg1.plot(rates,myprobs_delay_nov[i],lw=12,color=colors[2],ls='--',alpha=0.8,label=r'Delay Novel') fg1.set_xlim([0.01,25]) fg1.set_ylim([0,0.35]) fg1.set_yticks([0,0.15,0.3]) #fg2.set_xticks([0,0.1,0.2,0.3,0.4,0.5]) fg1.set_xlabel(r'Rate (Hz)',fontsize=45) fg1.set_ylabel(r'Distribution Rates',fontsize=45) fg1.tick_params(labelsize=40) fg1.set_title('(A)',fontsize=50,fontweight="bold",y=1.06) fg1.legend(loc=(0.6,0.18),numpoints=1,prop={'size':30}) inset_axes = inset_axes(fg1,width=5, height=3,loc=1,bbox_to_anchor=(0.33, 0.885),bbox_transform=fg1.figure.transFigure) for i in [index]: inset_axes.plot(rates,myprobs_delay_fam[i],lw=8,alpha=0.8,color=colors[0]) for i in [index]: inset_axes.plot(rates,myprobs_delay_nov[i],lw=8,ls='--',alpha=0.8,color=colors[0]) for i in [index]: inset_axes.plot(rates,myprobs_pres_fam[i],lw=8,alpha=0.8,color=colors[2]) for i in [index]: inset_axes.plot(rates,myprobs_pres_nov[i],lw=8,ls='--',alpha=0.8,color=colors[2]) inset_axes.set_xlim([25,100]) inset_axes.set_ylim([0,0.02]) inset_axes.set_xticks([25.,50,75,100]) inset_axes.set_yticks([0.02]) inset_axes.tick_params(labelsize=30) inset_axes.set_xlabel(r'Rate (Hz)',fontsize=30) inset_axes.set_ylabel(r'Dist. Rates',fontsize=30)