我正在尝试创建热图。 代码:
import plotly.express as px
fig = px.imshow(data.corr().values)
fig.update_layout(
title="Correlation matrix",
xaxis_title="X",
yaxis_title="Y",
coloraxis_colorbar=dict(
title="Your Title",
))
fig.show()
最佳答案
如果您不想要的话,可以明确指定图形的大小以删除此空白。例如:
import numpy as np
import pandas as pd
import plotly.express as px
data = np.random.randn(10, 10)
data = pd.DataFrame(data)
fig = px.imshow(data.corr().values)
fig.update_layout(
title="Correlation matrix",
xaxis_title="X",
yaxis_title="Y",
coloraxis_colorbar=dict(
title="Your Title"),
width = 700, height = 700,
autosize = False)
fig.show()
关于python - 在热图中绘制不必要的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68403568/