如何使用 Matplotlib 在 Seaborn jointplot 中自定義軸標籤?


要自定義 Seaborn jointplot 中的軸標籤,我們可以採取以下步驟

  • 設定圖形大小並調整子圖之間和周圍的填充。
  • 使用 numpy 建立 x 和 y 資料點。
  • 使用jointplot()方法在 Seaborn 中繪製聯合圖。
  • 要設定自定義軸標籤,我們可以使用 LaTex 表示或set_xlabel()方法屬性。
  • 要顯示圖形,請使用show()方法。

示例

import seaborn as sns
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.random.randn(1000,)
y = 0.2 * np.random.randn(1000) + 0.5
h = sns.jointplot(x, y, height=3.50)
h.ax_joint.set_xlabel('$\bf{X-Axis\ Label}$')
plt.show()

輸出

更新於: 01-06-2021

2000+ 人瀏覽

開始你的 事業

完成課程並獲得認證

開始學習
廣告