[英]Reduce Seaborn KDE Plot Margins
嗨,我有下面的代碼,可以在關節圖的邊緣生成多個KDE圖
h = sns.JointGrid('SECS', 'EPOCH', df)
for name, group in df.groupby("QUERY"):
sns.kdeplot(group["SECS"], ax=h.ax_marg_x, legend=False)
sns.kdeplot(group["EPOCH"], ax=h.ax_marg_y, vertical=True, legend=False)
h.ax_joint.plot(group["SECS"], group["EPOCH"], ".", ms=5)
我想知道如何限制邊距,以便圖形從0開始而不是從-20000開始,那里有很多死角。
您可以使用ax_joint
訪問JointGrid
的主圖,就像首先繪制數據一樣。 如果打印h.ax_joint
的類型, h.ax_joint
可以看到它是matplotlib.axes._subplots.AxesSubplot
。 因此,您可以像通常使用matplotlib一樣操縱軸的極限。
例如:
h = sns.JointGrid('SECS', 'EPOCH', df)
for name, group in df.groupby("QUERY"):
sns.kdeplot(group["SECS"], ax=h.ax_marg_x, legend=False)
sns.kdeplot(group["EPOCH"], ax=h.ax_marg_y, vertical=True, legend=False)
h.ax_joint.plot(group["SECS"], group["EPOCH"], ".", ms=5)
h.ax_joint.set_xlim(0,90000)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.