我有一个箱线图,需要删除x轴(“ user_type”和“ member_gender”)标签。给定以下格式,我该怎么办?
sb.boxplot(x="user_type", y="Seconds", data=df, color = default_color, ax = ax[0,0], sym='').set_title('User-Type (0=Non-Subscriber, 1=Subscriber)')
sb.boxplot(x="member_gender", y="Seconds", data=df, color = default_color, ax = ax[1,0], sym='').set_title('Gender (0=Male, 1=Female, 2=Other)')
答案 0 :(得分:0)
set(xticklabels=[])
应该删除刻度线标签
.set_title()
,则无法使用,但是可以使用.set(title='')
set(xlabel=None)
应该删除标签fig, ax = plt.subplots(2, 1)
g1 = sb.boxplot(x="user_type", y="Seconds", data=df, color = default_color, ax = ax[0], sym='')
g1.set(xticklabels=[])
g1.set(title='User-Type (0=Non-Subscriber, 1=Subscriber)')
g1.set(xlabel=None)
g2 = .boxplot(x="member_gender", y="Seconds", data=df, color = default_color, ax = ax[1], sym='')
g2.set(xticklabels=[])
g2.set(title='Gender (0=Male, 1=Female, 2=Other)')
g2.set(xlabel=None)
fig, ax = plt.subplots(2, 1)
g1 = sns.boxplot(y='score', x='par', data=df, ax=ax[0])
g2 = sns.boxplot(y='score', x='par', data=df, ax=ax[1])
plt.show()
fig, ax = plt.subplots(2, 1)
g1 = sns.boxplot(y='score', x='par', data=df, ax=ax[0])
g1.set(xticklabels=[])
g1.set(title='Test1')
g1.set(xlabel=None)
g2 = sns.boxplot(y='score', x='par', data=df, ax=ax[1])
g2.set(xticklabels=[])
g2.set(title='Test2')
g2.set(xlabel=None)
plt.show()