使用 pd.hist() 时如何定义 x 和 y 标签

How can I define x and y label when I use pd.hist()

我正在编码,我想在 X 轴上放置一个标签以改进我的图表以供一次演示。

import pandas as pd
train = pd.read_csv('titanic_train.csv')
train['Age'].hist(bins=30, alpha=0.4)
plt.show()

我想在 X 标签中放入 'Age' 文本。

一种实现方式是这样的:

import matplotlib.pyplot as plt

ax = train['Age'].hist(bins=30, alpha=0.4)
ax.set_xlabel("Age")
plt.show()