Turn off marginal distribution axes on jointplot using seaborn package

有些话、适合烂在心里 提交于 2020-12-01 06:15:03

问题


I like this particular plot and the ability to pass a function to the stat_func keyword to quickly plot up and visualize relationships between variables, but there's one thing. How do I 'turn off' or not plot the marginal distribution axes?

It looks nice but sometime I don't want this feature.

For example using this code:

import numpy as np
import seaborn as sns

x = np.arange(100) + np.random.randn(100)*20
y = np.arange(100) + np.random.randn(100)*20
sns.jointplot(x, y, kind='reg')

How can I remove the kde subplots on the top and right hand side of the main axes?


回答1:


You could use JointGrid directly:

from scipy import stats

g = sns.JointGrid(x, y, ratio=100)
g.plot_joint(sns.regplot)
g.annotate(stats.pearsonr)
g.ax_marg_x.set_axis_off()
g.ax_marg_y.set_axis_off()

enter image description here



来源:https://stackoverflow.com/questions/28032027/turn-off-marginal-distribution-axes-on-jointplot-using-seaborn-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!