plot_container.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:yt 作者: yt-project 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号