Mis a jour le 2019-12-02, 7:18

Heatmap et clustermap

Heatmap

heatmap : Pour la matrice suivante :
array([[ 0,  2,  4,  6,  8, 10],
       [ 0,  3,  6,  9, 12, 15],
       [ 0,  4,  8, 12, 16, 20],
       [ 0,  5, 10, 15, 20, 25],
       [ 0,  6, 12, 18, 24, 30],
       [ 0,  7, 14, 21, 28, 35]])
  
ar = numpy.array([0, 1, 2, 3, 4, 5]) mat = numpy.dot(ar.reshape(1, 6).T + 2, ar.reshape(1, 6)) df = pandas.DataFrame(mat, columns = ['A', 'B', 'C', 'D', 'E', 'F'], index = ['a', 'b', 'c', 'd', 'e', 'f']) seaborn.heatmap(df, annot = True, cbar = True, cmap = 'plasma') pyplot.tight_layout()

Clustermap

Utilise scipy pour faire un double clustering hierarchique.
On peut donner une array numpy ou un dataframe pandas : ar = numpy.array([[5, 4, 5, 6, 5], [6, 3, 4, 5, 1], [1, 6, 4, 2, 7], [4, 1, 2, 3, 0], [2, 7, 5, 3, 8]]) df = pandas.DataFrame(ar, columns = ['A', 'B', 'C', 'D', 'E'], index = ['a', 'b', 'c', 'd', 'e']) seaborn.clustermap(df, cmap = 'viridis', method = 'ward')

Copyright python-simple.com
programmer en python, tutoriel python, graphes en python, Aymeric Duclert