我正在尝试在python中制作2D绘图,但我不能为我的生活弄清楚如何使线条沿着箱子的外部而不是通过箱子。我希望每个方框都用线条勾勒出来。下面是我绘制数据帧“df”的代码。任何帮助将不胜感激!
from matplotlib import cm as cm
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111)
cmap = cm.get_cmap('jet', 30) # viridis
cax = ax1.imshow(df.corr(), interpolation="nearest", cmap=cmap)
ax1.grid(True, which='minor', color='black')
plt.title('Titanic Feature Correlation')
labels = [column for column in df]
ax1.set_xticks(np.arange(len(labels)))
ax1.set_xticklabels(labels,fontsize=5)
ax1.set_yticks(np.arange(len(labels)))
ax1.set_yticklabels(labels,fontsize=5)
fig.colorbar(cax, ticks=[1, .75, .5, .25, 0, -.25, -.5, -.75, -1])
plt.show()