我在哪里可以找到有关此参数的详细定义'joint_kws' seaborn的jointplot函数或Python中的matplotlib?



以下是此函数的说明:

def jointplot(x, y, data=None, kind="scatter", stat_func=stats.pearsonr,
color=None, size=6, ratio=5, space=.2,
dropna=True, xlim=None, ylim=None,
joint_kws=None, marginal_kws=None, annot_kws=None, **kwargs)

以下是最后几个参数的描述:

{joint, marginal, annot}_kws : dicts, optional
Additional keyword arguments for the plot components.
kwargs : key, value pairings
Additional keyword arguments are passed to the function used to
draw the plot on the joint Axes, superseding items in the
``joint_kws`` dictionary.

文档提到我可以传入像"joint_kws"或"marginal_kws"这样的字典来控制情节,但是你在哪里可以找到这些词典的定义和用法?我没有在官方文档中看到它。 谁能帮助我?感谢!

正如文档所述,这些字典被传递给用于在关节轴或边缘轴上绘制的绘图函数。因此,要传递的实际密钥取决于您执行的情节类型。

例如,如果您正在执行jointplot(..., kind="kde", ...)那么Seaborn将使用sns.kdeplot()在关节轴上进行绘图,因此可以在joint_kws=中提供可以传递给该函数的任何参数。查看sns.kdeplot()的定义,我发现我可以传递一个参数shade=("如果为 True,则在 KDE 曲线下的区域着色(或在数据为二元时用填充轮廓绘制("(,因此,我可以在joint_kws字典中传递该参数:

iris = sns.load_dataset("iris")
g = sns.jointplot("sepal_width", "petal_length", data=iris,kind="kde",
space=0, color="g", joint_kws=dict(shade=False))

如果我跑sns.jointplot(..., kind='scatter',...)那么Seaborn会用plt.scatter()来绘制实际的情节。我可以查看pyplot.scatter()的定义,看看我可以在字典中使用哪些键:

tips = sns.load_dataset("tips")
g = sns.jointplot(x="total_bill", y="tip", data=tips, kind='scatter', joint_kws=dict(marker='D', s=50))

最新更新