简体   繁体   English

在seaborn的同一个地块上的多个图表

[英]Multiple graphs on the same plot in seaborn

I'm trying to plot a bar style "factorplot" for some data, then plot a regular point style "factorplot" for my fit of that data on top of it. 我正在尝试为某些数据绘制一个条形样式“factorplot”,然后绘制一个常规的点样式“factorplot”,以便在其上方拟合该数据。 So for the data plot I can simply do : 所以对于数据图我可以简单地做:

sns.factorplot(x='x',y='yData',data=dataFrame,kind='bar')

And for the model plot I can simply do : 对于模型图我可以简单地做:

sns.factorplot(x='x',y='yModel',data=dataFrame,kind='point')

The problem is that if I then do : 问题是,如果我这样做:

sns.plt.show()

I get 2 separate figures instead of just one. 我得到2个单独的数字而不是一个。 Is there any simple way to tell seaborn to just plot them on the same graph ? 有没有简单的方法告诉seaborn只是在同一个图表上绘制它们?

As mentioned in the comments, this answer explains the basic architecture that accounts for why you see that behavior (two different figures), but it's possible to give a more specific answer to your question: 正如评论中所提到的, 这个答案解释了基本架构,它解释了为什么你会看到这种行为(两个不同的数字),但是你可以给出一个更具体的问题答案:

The tutorial explains that factorplot is mostly a convenience function that combines FacetGrid with a number of Axes-level functions for drawing categorical plots that share an API. 教程解释了factorplot主要是一个便利函数,它将FacetGrid与许多Axes级函数结合FacetGrid ,用于绘制共享API的分类图。 Since you aren't using the faceting options of factorplot , all you need to do is replace sns.factorplot(..., kind="bar") with sns.barplot(...) and sns.factorplot(..., kind="point") with sns.pointplot(...) . 由于您没有使用factorplot的分面选项,所以您需要做的就是用sns.barplot(...)sns.factorplot(..., kind="point")替换sns.factorplot(..., kind="bar") sns.factorplot(..., kind="point")sns.pointplot(...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM