问题
As suggested in the answer of question, it's possible to plot multiple Seanborn Jointplot by SeabornFig2Grid.
However, the colorbars aren't shown:
import matplotlib.pyplot as plt
import seaborn as sns;
sns.set(style="white", color_codes=True)
import seabornfig2grid as sfg
import matplotlib.gridspec as gridspec
iris = sns.load_dataset("iris")
g1 = sns.jointplot("sepal_width", "petal_length", data=iris,
kind="kde", space=0, color="g",
cbar=True, cbar_kws={"label": 'Normalized Densities'},
)
g2 = sns.jointplot("sepal_width", "petal_length", data=iris,
kind="kde", space=0, color="g",
cbar=True, cbar_kws={"label": 'Normalized Densities'},
)
fig = plt.figure(figsize=(13,8))
gs = gridspec.GridSpec(1, 2)
mg0 = sfg.SeabornFig2Grid(g1, fig, gs[0])
mg1 = sfg.SeabornFig2Grid(g2, fig, gs[1])
gs.tight_layout(fig)
Update/Solution
Here's my solution:
mg0 = sfg.SeabornFig2Grid(g1, fig, gs[0])
mg1 = sfg.SeabornFig2Grid(g2, fig, gs[1])
mappable0 = g1.fig.axes[0].collections[0]
mappable1 = g2.fig.axes[0].collections[0]
gs.tight_layout(fig)
fig.colorbar(mappable0, ax=mg0.fig.axes[0])
fig.colorbar(mappable1, ax=mg1.fig.axes[3])
来源:https://stackoverflow.com/questions/59966497/colorbar-not-shown-in-multiple-seaborn-jointplot