我正在尝试在带有边缘轴的密度图旁边绘制一个颜色条。它确实绘制了颜色条,但不幸的是不是在侧面。到目前为止,这就是尝试过的:
sns.jointplot(x,y, data=df3, kind="kde", color="skyblue", legend=True, cbar=True,
xlim=[-10,40], ylim=[900,1040])
Run Code Online (Sandbox Code Playgroud)
它看起来像这样:
我也尝试过这个:
from matplotlib import pyplot as plt
import seaborn as sns
import numpy as np
kdeplot = sns.jointplot(x=tumg, y=pumg, kind="kde")
plt.subplots_adjust(left=0.2, right=0.8, top=0.8, bottom=0.2)
cbar_ax = kdeplot.fig.add_axes([.85, .25, .05, .4])
plt.colorbar(cax=cbar_ax)
plt.show()
Run Code Online (Sandbox Code Playgroud)
但使用第二个选项时,我收到运行时错误:
No mappable was found to use for colorbar creation.
First define a mappable such as an image (with imshow) or a contour set (with contourf).
有谁知道如何解决这个问题?