Hello ,
I need to draw annotated heatmap which changes features (rows/columns) shown dynamically. When I draw for first time specific features lets say 9x9 matrix I got normal annotations.
But when added additional feature (matrix 10x10) I have issue with annotations are not shown at the right place. Has someone idea what can be the problem ?
Hi @empet,
thank you for your reply, but I am not sure if I understand how can I solve my issue based on provided link. Maybe some additional information: currently I have callback something like below:
@app.callback([Output("corr-matrix", "figure"),
Output("annotated-corr-matrix", "figure")
],
Input("datatable", "selected_columns")
)
def update_corr_matrix(selected_col):
...calculate correlation matrix values...
corr_matrix_fig = go.Figure(data=go.Heatmap(
z=corr, x=corr.columns, y=corr.columns, colorscale='rdylbu'))
#only show rounded value (full value on hover)
corr_text = np.around(corr.values, decimals=2)
font_colors = ['white', 'black']
x = y = corr.columns.tolist()
annot_corr_matrix_fig = go.Figure(data = ff.create_annotated_heatmap(corr.values, x=x, y=y, annotation_text=corr_text, colorscale='rdylbu',
font_colors=font_colors, showscale = False))
#set xaxis to bottom
corr_matrix_fig['layout']['xaxis']['side'] = 'bottom'
return corr_matrix, annot_corr_matrix_fig
else:
return {}, {}
and at every input I have different columns ie diff matrix 9x9 or 10x10. Before I thought that update to higher matrix is an issue but I set in Input of callback matrix 10x10 and I was not able to produce annotated heatmap. I am trying to return annotated heatmap figure to dcc.Graph element.
tnx!
Hi @empet,
I have tried with and without "data = "but with no success, result is the same as before. First I was using ff.create_annotated_heatmap then I decided to try go.Figure but it did not solve my issue.
In this case I have to create synthetic data and wirte down a code to reproduce your experiment. Could you please please, write down the steps of your code: how many heatmaps do you intend to plot, and whether from one to another, the size is changing.
Hi @empet,
thank you for your time and effort. My problem is following: I have some dataframe for example (5, 15) - datatable in dash, on every input in the callback I have different selected number of columns/features for which I produce corr matrix and want to plot annotated heatmap. If 3 columns are selected I need annotated heatmap 3x3, if 10 are selected I need 10x10, so size is changing, on every output graph should be updated accordingly to selected data on input. I need to plot one annotated heatmap.