I am trying to create heatmap using squares and labels (I will need to customize it in a special way, so I cannot use heatmap directly). There is a problem, however, that the text is cut.
Is there a way to fix it, so that the graph autofits the text?
Here goes the code to reproduce:
import numpy as np import plotly.graph_objects as go # generate value values = np.random.random((5, 10)) # initialize figure fig = go.Figure() # fill figure for i, row in enumerate(values): max_val = row.max() # add text for the row fig.add_trace(go.Scatter( x=[-0.2], y=[i + 0.5], text=['MY TEXT'], mode="text", textposition="middle left" )) # add square for each value in a row for j, val in enumerate(row): fig.add_trace(go.Scatter( x=[j,j,j+1,j+1,j], y=[i,i+1,i+1,i,i], fill="toself", mode='lines', fillcolor='blue', line=dict(width=0), opacity=val/max_val )) # figure layout fig.update_layout( height=400, width=600, showlegend=False, ) fig.show() https://stackoverflow.com/questions/66836604/no-autofit-for-plotly-scatter-text-element March 28, 2021 at 06:09AM

没有评论:
发表评论