python - Control individual linewidths in seaborn heatmap -


is possible widen linewidth sepcific columns , rows in seaborn heatmap?

for example, can heatmap

import numpy np; np.random.seed(0) import seaborn sns; sns.set() uniform_data = np.random.rand(10, 12) ax = sns.heatmap(uniform_data, linewidths=1.0) 

be transformed this:

enter image description here

it's possible, may lot of work. possible solution might shown below. involves plotting 6 different heatmaps , adjusting spacings such looks okish. 1 needs synchronize colorscaling , manually set colorbar.

import matplotlib import matplotlib.pyplot plt import numpy np; np.random.seed(0) import seaborn sns; sns.set()  data = np.random.rand(10, 12)  asp = data.shape[0]/float(data.shape[1]) figw = 8 figh = figw*asp  cmap = plt.cm.copper norm = matplotlib.colors.normalize(vmin= data.min(), vmax= data.max())  gridspec_kw = {"height_ratios":[9,1], "width_ratios" : [4,5,3]} heatmapkws = dict(square=false, cbar=false, cmap = cmap, linewidths=1.0, vmin= data.min(), vmax= data.max() )  tickskw =  dict(xticklabels=false, yticklabels=false)  left = 0.07; right=0.87 bottom = 0.1; top = 0.9 fig, axes = plt.subplots(ncols=3, nrows=2, figsize=(figw, figh), gridspec_kw=gridspec_kw) plt.subplots_adjust(left=left, right=right,bottom=bottom, top=top, wspace=0.1, hspace=0.1*asp ) sns.heatmap(data[:9,0:4], ax=axes[0,0], xticklabels=false, yticklabels=true, **heatmapkws) sns.heatmap(data[:9,4:9], ax=axes[0,1], xticklabels=false, yticklabels=false, **heatmapkws) sns.heatmap(data[:9,9:12], ax=axes[0,2],xticklabels=false, yticklabels=false, **heatmapkws)  sns.heatmap(data[9:,:4], ax=axes[1,0], xticklabels=true, yticklabels=true, **heatmapkws) sns.heatmap(data[9:,4:9], ax=axes[1,1], xticklabels=true, yticklabels=false, **heatmapkws) sns.heatmap(data[9:,9:12], ax=axes[1,2], xticklabels=true, yticklabels=false,**heatmapkws)  axes[1,0].set_yticklabels([9]) axes[1,1].set_xticklabels([4,5,6,7,8]) axes[1,2].set_xticklabels([9,10,11])  cax = fig.add_axes([0.9,0.1,0.03,0.8]) sm = matplotlib.cm.scalarmappable(cmap=cmap, norm=norm) sm.set_array([]) fig.colorbar(sm, cax=cax)  plt.show() 

enter image description here


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -