【发布时间】:2020-07-19 22:17:15
【问题描述】:
这是我Previous Question的后续内容
我有以下代码:
#Plot
cmap = plt.cm.GnBu_r
f, ax = plt.subplots(nrows=4,figsize=(20,10))
spec = f.add_gridspec(ncols = 1, nrows = 4, height_ratios = [1,1,1,.3])
ax0 = f.add_subplot(spec[0])
ax0 = sns.heatmap(df1,cbar=False,cmap=cmap)
ax1 = f.add_subplot(spec[1])
ax1 = sns.heatmap(df2,cbar=False,cmap=cmap)
ax2 = f.add_subplot(spec[2])
ax2 = sns.heatmap(df3,cbar=False,cmap=cmap)
ax3 = f.add_subplot(spec[3])
ax3 = sns.heatmap(df4,cbar=False,cmap=cmap)
axis = [ax0,ax1,ax2,ax3]
names = ['1', '2', '3','4']
for axi in axis:
n = axis.index(axi)
axi.set_title(str(names[n]))
axi.set(xticklabels=[])
axi.set_xlabel('')
axi.xaxis.set_visible(False)
h = axi.get_yticks()
w = axi.get_xticks()
axi.vlines(25, h[0] - 0.5, h[-1] + .5, linewidth=1, color="black")
axi.vlines(50,h[0]-0.5,h[-1]+.5, linewidth=1, color="black")
axi.vlines(75,h[0]-0.5,h[-1]+.5, linewidth=1, color="black")
axi.vlines(100,h[0]-0.5,h[-1]+.5, linewidth=2, color="black")
axi.set_ylabel('')
这给了我以下输出:
我已将要显示的名称涂黑,但我想知道如何隐藏其他 x 和 y 标签?例如所有小数。我认为它们与 4 个单独地块的 gridspec 框有关,但我不知道如何删除它们。我可以删除 xticklabels 和 xlabel 但它似乎不适用于小数点。
总结性问题: 如何删除图中的小数点?任何帮助将非常感激!谢谢!
【问题讨论】:
-
您添加了两次子图。一次 w 子图,第二次 w 你的 add_subplot 调用
-
感谢@JodyKlymak,这是有道理的,尽管没有两者我似乎无法使其工作?有什么建议可以复制相同的图形尺寸(具有高度比)但保留一个子图?
-
f= plt.figure(figsize=(20,10))和spec = f.add_gridspec(ncols = 1, nrows = 4, height_ratios = [1,1,1,.3])
标签: python pandas matplotlib seaborn