python - Plot on top of seaborn clustermap -


i generated clustermap using seaborn.clustermap. i'd draw/plot horizontal line on top of heatmap in figureenter image description here

i tried use matplotlib as:

plt.plot([x1, x2], [y1, y2], 'k-', lw = 10) 

but line not displayed. object returned seaborn.clustermap doesn't have properties in similar question. how can plot line?

here code generates "random" clustermap similar 1 posted:

import numpy np import seaborn sns import pandas pd import matplotlib.pyplot plt import random   data = np.random.random((50, 50)) df = pd.dataframe(data) row_colors = ["b" if random.random() > 0.2 else "r"  in range (0,50)] cmap = sns.diverging_palette(133, 10, n=7, as_cmap=true) result = sns.clustermap(df, row_colors=row_colors, col_cluster = false, cmap=cmap, linewidths = 0) plt.plot([5, 30], [5, 5], 'k-', lw = 10) plt.show() 

the axes object want hiding in clustergrid.ax_heatmap. code finds axis , uses ax.plot() draw line. use ax.axhline().

import numpy np import seaborn sns import pandas pd import matplotlib.pyplot plt import random   data = np.random.random((50, 50)) df = pd.dataframe(data) row_colors = ["b" if random.random() > 0.2 else "r"  in range (0,50)] cmap = sns.diverging_palette(133, 10, n=7, as_cmap=true) result = sns.clustermap(df, row_colors=row_colors, col_cluster = false, cmap=cmap, linewidths = 0) print dir(result)  # here see clustergrid has several axes objects hiding in ax = result.ax_heatmap  # important part ax.plot([5, 30], [5, 5], 'k-', lw = 10) plt.show() 

enter image description here


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -