I wonder how to place two independent SHAP beeswarm plots into the same figure but in different axes. I am using matplotlib version 3.4.2
, shap version 0.39.0
, and Python 3.8.2
. I am trying using a single figure and two axes but realize that the beeswarm method does not handle the axis as parameter (error: TypeError: beeswarm() got an unexpected keyword argument 'ax'
).
I am aware of this related question, but this is different since I am using SHAP API. Any recommendation is welcome. Thanks in advance.
from matplotlib import pyplot as plt
import shap
fig, axes = plt.subplots(1, 2, figsize=(35, 7), gridspec_kw = {"wspace":1.0})
shap.plots.beeswarm(explainer_a(X_test_a), max_display=10, ax=axes[0])
shap.plots.beeswarm(explainer_b(X_test_b), max_display=10, ax=axes[1])
plt.show()