aminnj / yahist

1D and 2D histogram objects
10 stars 3 forks source link

is there better way to change label size of colorbar #2

Closed mhl0116 closed 4 years ago

mhl0116 commented 4 years ago

Hi Nick,

I am trying to make label size of colorbar larger, the way I have come up with so far is a bit of convoluted, like the last 3 lines in the following:

" bin_eta2 = np.linspace(0,3,30) bin_eta3 = np.linspace(-0.5,0.5,25)

etadiff=np.c[ (abs(np_leadeta_micro) - abs(np_leadeta_nano))/abs(np_leadeta_micro), abs(np_leadeta_micro)] h_eta_diff = Hist2D(eta_diff, bins=[bin_eta3, bin_eta2])

fig4, axs4 = plt.subplots(1,1, figsize=(11,7)) im,ax = h_eta_diff.plot(ax=axs4,cmap="cividis")

axs4.tick_params(labelsize=16) axs4.set_xlabel("(|eta_micro|-|eta_nano|)/|eta_micro|", fontsize=16) axs4.set_ylabel("|eta_micro|", fontsize=16)

plt.delaxes(fig4.axes[1]) cb = plt.colorbar(im) cb.ax.tick_params(labelsize=16) "

I wonder if there is a cleaner way to do it?

Thanks, Hualin

aminnj commented 4 years ago

Hi Hualin,

I don't know of a cleaner way. Only thing I noticed is that you can pass colorbar=False since you're making it yourself manually later (to allow more customization):

im,ax = h_eta_diff.plot(ax=axs4,cmap="cividis", colorbar=False)

and then you can get rid of this line:

plt.delaxes(fig4.axes[1])
mhl0116 commented 4 years ago

Thanks, actually I was mainly not happy about "delaxes", what you suggested is good for my need.