0

I'm trying to plot a two plots in a figure using subplot. The first picture is generated using ax1.plot(...) and the second one using seaborn specifying the axis where I want to plot the figure. This is an example.

kind = "boxen"
fig, (ax1,ax2) = plt.subplots(1, 2, figsize=(15, 5), gridspec_kw={'width_ratios': [2, 1]})

X = np.arange(0,7,0.1)
ax1.plot(X,np.sin(X))

sns.catplot( x= "Dataset", y = "RSE", hue="Model",
           data=df, kind=kind, ci="sd", ax = ax2)

And that is what appears when I run the code:

enter image description here

My questions are, how I can solve this? Why is generating a new figure?

oscarcapote
  • 373
  • 1
  • 3
  • 14
  • 4
    `catplot` is a "figure-level function" that always creates its own figure with one or more subplots (and that should give a warning or an error if you provide an `ax=` parameter). You can directly use `sns.boxenplot(...., ax=ax2)` for the equivallent "axes-level" function. See https://seaborn.pydata.org/tutorial/function_overview.html#figure-level-vs-axes-level-functions – JohanC Apr 26 '22 at 15:45

0 Answers0