Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Scaling of heat map compared with hierarchical cluster using python

Hi,
I am trying to add a hierarchical dendrogram to a heat map when I plot the heat map the scale is fine her

column_names_test = list(datatest)
import plotly.plotly as py
import plotly.graph_objs as go
data = [go.Heatmap( z=datatest.values.tolist(), colorscale=‘Viridis’, x=column_names_test,y=datatest.index)]
import plotly.offline as offline
import plotly.graph_objs as go
offline.init_notebook_mode()

Plot!

offline.iplot(data, filename=‘dendrogram_with_heatmap’)

but when I add the hierarchical dendrogram to the figure the scale becomes

Initialize figure by creating upper dendrogram

figure = FF.create_dendrogram(linkage_matrix, labels=datatest.index, orientation=‘right’)
for i in range(len(figure[‘data’])):
figure[‘data’][i][‘xaxis’] = ‘x1’

data_dist = pdist(linkage_matrix)
heat_data = squareform(data_dist)
heat_data = heat_data[dendro_leaves,:]
heat_data = heat_data[:,dendro_leaves]

heatmap = Data([
Heatmap(
#x = column_names_test,
y = datatest.index,
z = datatest.values.tolist(),
colorscale = ‘YIGnBu’
)
])

heatmap[0][‘y’] = figure[‘layout’][‘yaxis’][‘tickvals’]
###heatmap[0][‘x’] = dendro_side[‘layout’][‘xaxis’][‘tickvals’]

Add Heatmap Data to Figure

figure[‘data’].extend(Data(heatmap))

import plotly.offline as offline
import plotly.graph_objs as go
#datatest.index
offline.init_notebook_mode()

Plot!

offline.iplot(figure, filename=‘dendrogram_with_heatmap’)

My problem is how to scale the heat map making it larger compared with the dendrogram. How to add this scaling - thanks?

What is linkage_matrix here? I think I know what your problem is but I cannot be sure unless I know the details of your program!