如何使用 Seaborn 中的“色相”引數繪製聯合圖?(Matplotlib)


要使用 Seaborn 中的色相引數繪製聯合圖,我們可以採取以下步驟:

步驟

  • 設定影像大小並調整子圖之間和周圍的填充。
  • 使用 numpy 建立**x**資料點。
  • 使用一些曲線資料建立一個字典。
  • 為表格資料建立一個數據框架。
  • 使用**jointplot()**方法建立一個聯合圖。
  • 要顯示影像,請使用**show()**方法。

舉例

from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns
import numpy as np

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x = np.linspace(0, 1, 5)

d = {
      'y=sin(x)': np.sin(x),
      'y=cos(x)': np.cos(x),
      'y=x': x,
   }
df = pd.DataFrame(d)
jg = sns.jointplot(data=df, x="y=sin(x)", y="y=cos(x)",
                     height=3.5, hue="y=x")
plt.show()

輸出

更新於:16-6-2021

326 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.