Seaborn: catplot & relplot do not use provided ax: two frames appear

Created on 8 Oct 2018  路  2Comments  路  Source: mwaskom/seaborn

catplot:
import seaborn as sns
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=[10,5])
titanic = sns.load_dataset("titanic")
sns.catplot(ax=ax, x="sex", y="survived", hue="class", kind="bar", data=titanic);

seaborn

relplot:
fig, ax = plt.subplots(figsize=[10,5])
titanic = sns.load_dataset("titanic")
sns.relplot(ax=ax, x="sex", y="survived", hue="class", data=titanic);
plt.title("This plot is active")

relplot

barplot does work as expected:
fig, ax = plt.subplots(figsize=[10,5])
titanic = sns.load_dataset("titanic")
sns.barplot(ax=ax, x="sex", y="survived", hue="class", data=titanic);
plt.title("This plot is active")

barplot

I am expecting both catplot and relplot to also show exactly one frame instead of two

Most helpful comment

I am just going to add this here referenced from https://github.com/mwaskom/seaborn/issues/1514 in case someone like me stumbles upon this issue when using catplot with subplots.

plt.close(2) helps to hide the 2nd empty graph

All 2 comments

I am just going to add this here referenced from https://github.com/mwaskom/seaborn/issues/1514 in case someone like me stumbles upon this issue when using catplot with subplots.

plt.close(2) helps to hide the 2nd empty graph

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JanHomann picture JanHomann  路  3Comments

queryous picture queryous  路  4Comments

amelio-vazquez-reina picture amelio-vazquez-reina  路  4Comments

TDaltonC picture TDaltonC  路  3Comments

sofiatti picture sofiatti  路  4Comments