7

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. 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. Is there any simple way to tell seaborn to just plot them on the same graph ?

ticster
  • 744
  • 2
  • 5
  • 19
  • Not sure it is the solution bug if you do `g = sns.factorplot(x='x',y='yData',data=dataFrame,kind='bar')`, then `g` will be a `FacetGrid`, maybe you can use these axes (`g.ax`) for the next factorplot ? – mgc Feb 09 '16 at 22:34
  • 2
    Possible duplicate of [Plotting with seaborn using the matplotlib object-oriented interface](http://stackoverflow.com/questions/23969619/plotting-with-seaborn-using-the-matplotlib-object-oriented-interface) – mwaskom Feb 09 '16 at 22:36
  • @mgc I don't think that's possible for a factor plot – ticster Feb 09 '16 at 22:57
  • @mwaskom This certainly enlightens me somewhat as to what's going on, I guess I'll try to go from there and find my own solution, perhaps ditching factorplot for an "axes-level" fucntion, but I'll keep the question up in case someone has something else in mind. – ticster Feb 09 '16 at 22:59
  • You might be lucky to get any other ideas - mwaskom is, I believe, the author and maintainer of seaborn... – J Richard Snape Feb 09 '16 at 23:36
  • @JRichardSnape Oh well, back to regular pyplot for this task then. – ticster Feb 09 '16 at 23:37

1 Answers1

5

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. 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(...).

Community
  • 1
  • 1
mwaskom
  • 46,693
  • 16
  • 125
  • 127