[英]plotly express heatmap cell size
How can i change the size of cells in a plotly express heatmap?如何更改 plotly express 热图中的单元格大小? I would need bigger cells我需要更大的细胞
import plotly.express as px
fig1 = px.imshow(df[col],color_continuous_scale='Greens')
fig1.layout.yaxis.type = 'category'
fig1.layout.xaxis.type = 'category'
fig1.layout.yaxis.tickmode = 'linear'
fig1.layout.xaxis.tickmode = 'linear'
fig1.layout.xaxis.tickangle = 65
fig1.layout.autosize = True
fig1.layout.height = 500
fig1.layout.width = 500
fig1.show()
Result (very narrow)结果(非常窄)
'px' may not make it square due to the color bar, so why not use 'go'?由于颜色条,'px' 可能无法使它成为正方形,那么为什么不使用 'go' 呢?
import plotly.graph_objects as go
fig = go.Figure(data=go.Heatmap(
z=[[1, 20, 30],
[20, 1, 60],
[30, 60, 1]]))
fig.show()
Set the graph size.设置图形大小。
fig.layout.height = 500
fig.layout.width = 500
Examples at px px 上的示例
import plotly.express as px
data=[[1, 25, 30, 50, 1], [20, 1, 60, 80, 30], [30, 60, 1, 5, 20]]
fig = px.imshow(data,
labels=dict(x="Day of Week", y="Time of Day", color="Productivity"),
x=['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
y=['Morning', 'Afternoon', 'Evening']
)
fig.update_xaxes(side="top")
fig.layout.height = 500
fig.layout.width = 500
fig.show()
A little late, but if you want the cells to be wider, use this:有点晚了,但如果你想让单元格更宽,使用这个:
fig1 = px.imshow(df[col],color_continuous_scale='Greens', aspect='auto')
Setting the aspect argument to "auto" will fill the plotting area using non-square tiles.将 aspect 参数设置为“auto”将使用非方形图块填充绘图区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.