Python 如何绘制非方形Seaborn连接地块或连接网格

Python 如何绘制非方形Seaborn连接地块或连接网格,python,matplotlib,plot,data-visualization,seaborn,Python,Matplotlib,Plot,Data Visualization,Seaborn,我正在尝试使用Seaborn的JointGrid绘制非对称数据。我可以让它使用相等的纵横比,但是我有不需要的空白: 如何去除填充物?这两个方面的文档都很简单 大小:数字,可选 图形的大小(将是正方形) 我还尝试向jointplot和JointGrid以及ylim提供区段kwarg,但没有成功 import numpy as np import seaborn as sns import matplotlib.pyplot as plt x = np.random.normal(0.0, 10.

我正在尝试使用Seaborn的JointGrid绘制非对称数据。我可以让它使用相等的纵横比,但是我有不需要的空白:

如何去除填充物?这两个方面的文档都很简单

大小:数字,可选

图形的大小(将是正方形)

我还尝试向jointplot和JointGrid以及
ylim
提供
区段
kwarg,但没有成功

import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
x = np.random.normal(0.0, 10.0, 1000)
y = np.random.normal(0.0, 1.0, 1000)
joint = sns.jointplot(x, y)
joint.plot_marginals(sns.distplot, kde=False)
joint.ax_joint.set_aspect('equal')  # equal aspect ratio
plt.show() 

我自己偶然发现了这个问题,正在寻找答案。找到答案后,我想我应该发布解决方案。由于
jointplot
代码似乎非常坚持让图形为正方形,我不知道这是否被视为不好的做法,但无论如何

如果我们查看
jointplot
代码并将其跟随到
JointGrid
,则
size
参数到
jointplot
(同样
JointGrid
)将用于以下表达式:

f = plt.figure(figsize=(size, size))
# ... later on
self.fig = f
因此,要获得非方形的
JointGrid
绘图,只需运行:

grid = sns.jointplot(...)
grid.fig.set_figwidth(6)
grid.fig.set_figheight(4)
grid.savefig("filename.png", dpi=300)

对于6x4图形。

对于那些使用Seaborn进入Jupyter笔记本的人,我建议在
sns.jointplot()
命令之后调用
set\u figwidt()
set\u fighight()

my_plot=sns.jointplot(x="K",y="errori",data=risultati , kind="scatter")
my_plot.fig.set_figwidth(13)

您需要设置
ylim
xlim
参数,这将x轴和y轴限制在您指定的元组范围内:

e、 g

sns.jointplot(x=“n\u估计量”,y=“学习率”,数据=数据,
color=“#172235”,高度=8,比率=10,间距=0,

ylim=(0,1.1),xlim=(-20310))#您对图形的纵横比或hexbin单元的纵横比有问题吗?您好,mwaskom,图形本身。我想去掉填充,使其非正方形,因为我的数据是我的坐标不是正方形。我建议您自己使用matplotlib命令设置图形。