def set_background_color(self, field, color=None):
"""set the background color to match provided color
Parameters
----------
field : string
the field to set the colormap
if field == 'all', applies to all plots.
color : string or RGBA tuple (optional)
if set, set the background color to this color
if unset, background color is set to the bottom value of
the color map
"""
actual_field = self.data_source._determine_fields(field)[0]
if color is None:
cmap = self._colormaps[actual_field]
if isinstance(cmap, string_types):
try:
cmap = yt_colormaps[cmap]
except KeyError:
cmap = getattr(matplotlib.cm, cmap)
color = cmap(0)
if LooseVersion(matplotlib.__version__) < LooseVersion("2.0.0"):
self.plots[actual_field].axes.set_axis_bgcolor(color)
else:
self.plots[actual_field].axes.set_facecolor(color)
return self
评论列表
文章目录