The following helpers do the trick for me:
def set_foregroundcolor(ax, color):
'''For the specified axes, sets the color of the frame, major ticks,
tick labels, axis labels, title and legend
'''
for tl in ax.get_xticklines() + ax.get_yticklines():
tl.set_color(color)
for spine in ax.spines:
ax.spines[spine].set_edgecolor(color)
for tick in ax.xaxis.get_major_ticks():
tick.label1.set_color(color)
for tick in ax.yaxis.get_major_ticks():
tick.label1.set_color(color)
ax.axes.xaxis.label.set_color(color)
ax.axes.yaxis.label.set_color(color)
ax.axes.title.set_color(color)
lh = ax.get_legend()
if lh != None:
lh.get_title().set_color(color)
lh.legendPatch.set_edgecolor(color)
labels = lh.get_texts()
for lab in labels:
lab.set_color(color)
def set_backgroundcolor(ax, color):
'''Sets the background color of the current axes (and legend).
Use 'None' (with quotes) for transparent. To get transparent
background on saved figures, use:
pp.savefig("fig1.svg", transparent=True)
'''
ax.patch.set_facecolor(color)
lh = ax.get_legend()
if lh != None:
lh.legendPatch.set_facecolor(color)
···
--
Christopher Brown, Ph.D.
Associate Research Professor
Department of Speech and Hearing Science
Arizona State University
http://pal.asu.edu