我想在x轴上创建仅带有刻度和标签的箱形图(水平)。但是,当循环到达轴= 12时,即使将其从轴= 1移到了轴= 11,它也会在y轴上添加刻度和标签。
代码:
import matplotlib.pyplot as plt
import seaborn as sns
fig,axs = plt.subplots(12,3,figsize=(15,50),dpi=200)
fig.suptitle("Box plot for all 34 features",fontsize=16)
fig.tight_layout()
plt.subplots_adjust(top=0.96)
i=1
for column in undersampled_data:
if (column == 'TimeStamp' or column == 'Status'):
continue
ax = fig.add_subplot(12,i)
ax.set_title(column)
sns.boxplot(undersampled_data[column],palette="Set2")
ax.set_xlabel('')
# Removing y ticks and y labels
frame1 = plt.gca()
frame1.axes.yaxis.set_ticklabels([])
frame1.axes.get_yaxis().set_ticks([])
print(i," ",column)
i+=1
for j in range(0,(len(axs)-1)):
fig.delaxes(axs.flatten()[j])
fig.subplots_adjust(hspace=0.4)