plot - python: how to set the same colormap for 3 subplots -


i using python draw figure 3 subplots. want set colormap hot each subplot , code like:

fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(20,15)) count = 0 ax in axes.flat:     count += 1     if count == 1:         im = ax.imshow(data_in_array, interpolation='nearest',vmin=0, vmax=150)         ax.set_xticks(range(24))         ax.set_xticklabels(('6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','0','1','2','3','4','5'),fontsize=15)         ax.set_yticks(range(8))         ax.set_yticklabels(('belltown', 'downtown', 'industrial district', 'wallingford', 'university district', 'capitol hill', 'lakecity','ballard'),fontsize=15)         ax.set_title('arriving hours of travel survey',fontsize=15)         plt.hot()      if count == 2:         im = ax.imshow(data_out_array, interpolation='nearest',vmin=0, vmax=150)         ax.set_xticks(range(24))         ax.set_xticklabels(('6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','0','1','2','3','4','5'),fontsize=15)         ax.set_yticks(range(8))         ax.set_yticklabels(('belltown', 'downtown', 'industrial district', 'wallingford', 'university district', 'capitol hill', 'lakecity','ballard'),fontsize=15)         ax.set_title('leaving hours of travel survey',fontsize=15)         plt.hot()      if count == 3:         im = ax.imshow(data_stay_array, interpolation='nearest',vmin=0, vmax=150)         ax.set_xticks(range(24))         ax.set_xticklabels(('6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','0','1','2','3','4','5'),fontsize=15)         ax.set_yticks(range(8))         ax.set_yticklabels(('belltown', 'downtown', 'industrial district', 'wallingford', 'university district', 'capitol hill', 'lakecity','ballard'),fontsize=15)         ax.set_title('stay hours of travel survey',fontsize=15)         plt.hot()      fig.subplots_adjust(right=0.8) cbar_ax = fig.add_axes([0.75, 0.1, 0.03, 0.8]) fig.colorbar(im, cax=cbar_ax) plt.show() 

however, plot like: enter image description here

the first 1 not hot colormap, idea fix that?

when plotting on axes, need set global colorbar before plotting. hence, need have plt.hot() call before first ax.imshow().


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -