Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
Couple of issues I've found.
deflatex_float(f,pos=0):float_str="{0:.2g}".format(f)if"e"infloat_str:base,exponent=float_str.split("e")returnr"${0} \times 10^{{{1}}}$".format(base,int(exponent))else:returnr"${}$".format(float_str)formatter=FuncFormatter(latex_float)corr=np.corrcoef(data['x'],data['y'])[0,1]fig,ax=pl.subplots(figsize=figsize)hist,_,_,im=ax.hist2d(data['x'],data['y'],norm=LogNorm(),bins=(bins_x,bins_y) ,alpha=0.75,cmap=cmap)cbar=fig.colorbar(im,ticks=[0.,1.,2.,5.,10.,20.,50.,100.,200.,500.,1000.,2000.,5000.],format=formatter)cbar.set_label('number density',fontsize=labelsize,labelpad=79)cbar.ax.tick_params(labelsize=labelsize-6,width=3,length=15)cbar.ax.minorticks_on()ax.set_xlabel(label_x,fontsize=labelsize)ax.set_ylabel(label_y,fontsize=labelsize)ax.grid(True,which='both',linewidth=3,linestyle='--',alpha=0.5)ax.text(0.95,0.05,'$\mathrm{{Corr}} = {:0.4f}$'.format(corr),transform=ax.transAxes,fontsize=labelsize,verticalalignment='bottom',horizontalalignment='right',bbox=textprops)ax.tick_params(axis='both',which='major',labelsize=labelsize-6)pickle.dump(ax,file('ZH_ax.pkl','w+'))fig.close()
As it is, the code gives the following error:
Traceback (most recent call last): File "make_plots_new.py", line 124, in <module> pickle.dump(fig, file('ZH_ax.pkl', 'w+')) File "/lib/python2.7/copy_reg.py", line 70, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__TypeError: can't pickle instancemethod objects
If I exclude the label formatter function in thecolorbar
, I get an error of
Traceback (most recent call last): File "make_plots_new.py", line 124, in <module> pickle.dump(fig, file('ZH_ax.pkl', 'w+'))cPickle.UnpickleableError: Cannot pickle <type 'Image'> objects
How can one pickle?