[英]setting axis labels in axes from matplotlib
I'm trying the following code to plot some graphs: 我正在尝试以下代码来绘制一些图形:
fig = plt.figure(figsize=(10, 20))
for idx, col in enumerate(['Pclass', 'Sex']):
ax = fig.add_subplot(2, 1, idx+1)
_ = ax.set(ylabel='Counts')
_ = sns.countplot(x=col, hue='Survived', data=full, ax=ax)
The output I'm getting is: 我得到的输出是:
As you can see the y
label is set as the seaborn
countplot
default label 'count'
, but I want to change it to 'Counts'
. 如您所见, y
标签设置为seaborn
countplot
默认标签'count'
,但我想将其更改为'Counts'
。 I've tried the axes
method set_ylabel
and set with ylabel
argument and got no changes in the graphs. 我尝试了axes
方法set_ylabel
并使用ylabel
参数进行设置,但图形没有变化。 What am I doing wrong? 我究竟做错了什么?
Can you try the following, changing the ylabel
after plotting 您可以尝试以下操作,在绘制后更改ylabel
fig = plt.figure(figsize=(10, 20))
for idx, col in enumerate(['Pclass', 'Sex']):
ax = fig.add_subplot(2, 1, idx+1)
sns.countplot(x=col, hue='Survived', data=full, ax=ax)
ax.set_ylabel('Counts')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.