グラフを整える
plt.subplots() は axes オブジェクトを返すため、.set_title()、.set_xlabel()、.set_ylabel() メソッドを使ってグラフにラベルを追加できます。
この演習はコースの一部です
R ユーザーのための Python
演習の手順
- axes に対して
.set_title()メソッドを使い、グラフのタイトルを'Histogram'に設定しましょう。 - axes に対して
.set_xlabel()メソッドを使い、x 軸のラベルを'Total Bill'に設定しましょう。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
import matplotlib.pyplot as plt
import seaborn as sns
# Create a figure with 1 axes
fig, ax = plt.subplots()
# Draw a histplot
ax = sns.histplot(tips['total_bill'], kde = True)
# Label the title and x axis
ax.____(____)
____
plt.show()