Memoles sebuah figur
Karena plt.subplots() mengembalikan objek axes, Anda dapat menggunakan metode .set_title(), .set_xlabel(), dan .set_ylabel() untuk menambahkan label pada figur Anda.
Latihan ini adalah bagian dari kursus
Python untuk Pengguna R
Petunjuk latihan
- Gunakan metode
.set_title()pada axes untuk memberi label plot:'Histogram'. - Gunakan metode
.set_xlabel()pada axes untuk memberi label plot:'Total Bill'.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
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()