Seaborn lmplot() สร้าง FacetGrid ไม่ใช่ Axes ตรงๆ ต้องใช้ plt.gca() ได้ axes แล้วค่อย set_title()
ตัวอย่างโค้ด
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
df = pd.DataFrame({
"X-Axis": [np.random.randint(10) for i in range(10)],
"Y-Axis": [i for i in range(10)]
})
bar_plot = sns.lmplot(x='X-Axis', y='Y-Axis', data=df, height=3.5)
ax = plt.gca()
ax.set_title("Random Data lmplot")
plt.show()
ผลลัพธ์
lmplot พร้อม title "Random Data lmplot"
