基於以前的答案我添加了兩行設置彩條的框顏色和彩條的刻度顏色:
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import randn
fig = plt.figure()
data = np.clip(randn(250,250),-1,1)
cax = plt.imshow(data, interpolation='nearest')
title_obj = plt.title('my random fig') #get the title property handler
plt.setp(title_obj, color='w') #set the color of title to white
axes_obj = plt.getp(cax,'axes') #get the axes' property handler
plt.setp(plt.getp(axes_obj, 'yticklabels'), color='w') #set yticklabels color
plt.setp(plt.getp(axes_obj, 'xticklabels'), color='w') #set xticklabels color
color_bar = plt.colorbar()
plt.setp(plt.getp(color_bar.ax.axes, 'yticklabels'), color='w') # set colorbar
# yticklabels color
##### two new lines ####
color_bar.outline.set_color('w') #set colorbar box color
color_bar.ax.yaxis.set_tick_params(color='w') #set colorbar ticks color
##### two new lines ####
plt.setp(cbytick_obj, color='r')
plt.savefig('temp.png')
plt.savefig('temp3.png', facecolor="black", edgecolor="none")
我會建議尋找到這個[舊的問題(http://stackoverflow.com/questions/6485000/python-matplotlib-colorbar-setting -TICK-formator定位器,改變蜱標籤)。 – cosmosis 2012-03-12 08:21:23