So far, I have managed to spawn a legend box and have managed to put it outside the chart. But it is showing the same colours for both the labels (white and white) whereas I would prefer it to show white and gray.
import missingno as msno
msno.matrix(X_train, figsize=(15,10), sparkline=False, p=0);
plt.legend(['missing','not missing'],loc='center left', bbox_to_anchor=(1, 0.5))
You'll have to craft the legend by hand. matplotlib
has a legend guide showing how you can do this. The section describing "proxy artists" in particular is relevant to your use case. I haven't tested it, but the following should work:
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import missingno as msno
msno.matrix(...your data...)
gray_patch = mpatches.Patch(color='gray', label='Data present')
white_patch = mpatches.Patch(color='white', label='Data absent ')
plt.legend(handles=[gray_patch, white_patch])
plt.show()