要仅为当前交互式会话或一个脚本更改默认颜色图,请使用
import matplotlib as mplmpl.rc('image', cmap='gray')对于
matplotlib2.0之前的版本,您必须使用rcParams字典。在新版本中仍然有效。
import matplotlib.pyplot as pltplt.rcParams['image.cmap'] = 'gray'
要更改默认颜色图,请永久编辑matplotlibrc配置文件并添加该行
image.cmap:gray。根据需要,将灰色值替换为任何其他有效的颜色图。配置文件应位于
~/.config/matplotlib/matplotlibrc,但您可以通过找出确切的位置
mpl.matplotlib_fname()
如果您在不同的虚拟环境中有多个matplotlib版本,这将特别有用。
另请参见http://txt.arboreus.com/2014/10/21/how-to-set-default-colormap-in-
matplotlib.html
和Matplotlib的常规配置http://matplotlib.org/users/customizing
.html



