seaborn을 사용하는 히트맵이 있고 아래 4번째 플롯의 높이를 조정하려고 합니다. 데이터 행이 2개뿐이고 더 많은 행이 있는 것을 볼 수 있습니다.
다음 코드를 사용하여 플롯을 만들었습니다.
f, ax = plt.subplots(nrows=4,figsize=(20,10))
cmap = plt.cm.GnBu_r
sns.heatmap(df,cbar=False,cmap=cmap,ax=ax[0])
sns.heatmap(df2,cbar=False,cmap=cmap,ax=ax[1])
sns.heatmap(df3,cbar=False,cmap=cmap,ax=ax[2])
sns.heatmap(df4,cbar=False,cmap=cmap,ax=ax[3])
본질적으로 4 번째 플롯을 높이가 더 작아서 다른 3 개를 늘리는 다음 단계를 아는 사람이 있습니까? 네 번째 플롯에는 일반적으로 항상 2-3이 있고 다른 플롯에는 대부분 6-7이 있습니다. 매우 감사합니다!
일반적으로 matplotlib에서는 꽤 펑키하고 지루합니다. 하지만 여기 있습니다!
f = plt.figure(constrained_layout = True)
specs = f.add_gridspec(ncols = 1, nrows = 4, height_ratios = [1,1,1,.5])
for spec, df in zip(specs, (df, df2, df3, df4)):
ax = sns.heatmap(df,cbar=False,cmap=cmap, ax=f.add_subplot(spec))
You can change the heights relative to each other using the height_ratios. You could also implement a wdith_ratios parameter if you desired to change the relative widths. You could also implement a for loop to iterate over the graphing.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다