How can I add grid lines (vertically and horizontally) to a seaborn
catplot? I found a possibility to do that on a boxplot, but I have multiple facets and therefore need a catplot instead. And in contrast to this other answer, catplot does not allow an ax
argument.
This code is borrowed from here.
import seaborn as sns
sns.set(style="ticks")
exercise = sns.load_dataset("exercise")
g = sns.catplot(x="time", y="pulse", hue="kind", data=exercise)
plt.show()
Any ideas? Thank you!
EDIT: The provided answer is working, but for faceted plots, only the last plot inherits the grid.
import seaborn as sns
sns.set(style="ticks")
exercise = sns.load_dataset("exercise")
g = sns.catplot(x="time", y="pulse", hue="kind", col="diet", data=exercise)
plt.grid()
plt.show()
Can someone explain to me why and how to fix it?