Jancer Lima
Jancer Lima

Reputation: 944

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

I'm coding and I want to put one label in X axis to improve my graph for one presentation.

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

I want to put in X label the 'Age' text.

Upvotes: 0

Views: 37

Answers (1)

ferhen
ferhen

Reputation: 653

One way to achieve that is like this:

import matplotlib.pyplot as plt

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

Upvotes: 1

Related Questions