Search code examples
pythonseabornswarmplot

How to plot multiple swarmplots in a single figure?


I would like to plot multiple swarmplots in a single figure. I think swarmplot is one of the seaborn plots that should be able to do this, as it takes an axes keyword. However (with a freshly updated anaconda, matplotlib and seaborn) the following code :

import seaborn as sb
import matplotlib.pyplot as plt
tips = sb.load_dataset("tips")
f, ax = plt.subplots(2,2)
sb.swarmplot(x="size", y="total_bill", data=tips, axes=ax[0,0])

Gives the following error (at the end of a long traceback):

ValueError: Can not reset the axes.  You are probably trying to re-use an artist in more than one Axes which is not supported

I Googled and can't find any mention of this error. Is it not possible to draw a swarmplot into a subplot?

Thanks.


Solution

  • You want to use ax=, not axes=.