
在中间我想添加一个sns.regplot.在边缘两个sns.distplots或直方图.
这不是问题,但我想以不同的方式保留所有三个pplot,并为它们三个添加不同的功能和标签.
但我无法解决问题,如果我只使用预定义的方法如何获取图的实例:
g = sns.JointGrID(x="total_bill",y="tip",data=tips)g = g.plot(sns.regplot,sns.distplot)
手动 *** 纵那些.
或者反过来创建一个regplot和两个distplot实例,我定义了我的方式然后将它们添加到JointGrID,这意味着,但不幸的是,这些以下方法不存在或不起作用那样:
g = sns.JointGrID(x="total_bill",data=tips)g.add_joint(myreg) # That would be great but doesn't workg.ax_marg_x.add(mydist1) # Just invented codeg.ax_marg_y.add(mydist2) # Just to show you,the way I'd like to solve the issue
你能给我一个建议吗,如何解决这个问题?
解决方法 那么,documentation has a few examples.如果你想在两个边缘上都有相同的distPlot:g = sns.JointGrID(x="total_bill",data=tips)g = g.plot_joint(plt.scatter,color=".5",edgecolor="white")g = g.plot_marginals(sns.distplot,kde=True,color=".5")
或者如果你想在每个边缘上有不同的情节
g = sns.JointGrID(x="total_bill",data=tips)g = g.plot_joint(sns.regplot,color="m")_ = g.ax_marg_x.hist(tips["total_bill"],color="b",Alpha=.6,bins=np.arange(0,60,5))_ = g.ax_marg_y.hist(tips["tip"],color="r",orIEntation="horizontal",12,1))
然后花了2秒的时间进行实验,以确保您可以将自己的自定义绘图函数传递给marginals和jointplot,并且必须设置断点以确定哪个参数确定了边缘图的方向
def customJoint(x,y,*args,**kwargs): plt.scatter(x,color='red')def custommarginal(x,**kwargs): sns.distplot(x,color='green',vertical=kwargs['vertical'])g = sns.JointGrID(x="total_bill",data=tips)g = g.plot(customJoint,custommarginal)总结
以上是内存溢出为你收集整理的如何将手动定制的seaborn图添加到JointGrid / jointplot全部内容,希望文章能够帮你解决如何将手动定制的seaborn图添加到JointGrid / jointplot所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)