我希望能通过添加白色背景使我的色条更加明显。由于色条位于图片内部,有时很难读取。以下是没有白色背景的代码:
import matplotlib.pyplot as plt
import numpy as np
a=np.random.rand(10,10)
fig=plt.figure()
ax=fig.add_axes([0,0,1,1]) #fill the entire axis
im=ax.imshow(a)
cbaxes=fig.add_axes([0.8,0.1,0.03,0.8]) #add axis for colorbar, define size
cb=fig.colorbar(im,cax=cbaxes) #make colorbar
#cb.outline.set_color('white') #this does not work
fig.show()