PMIPlot.py 文件源码

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

项目:Visualization 作者: nwrush 项目源码 文件源码
def _update_colors(self, color_spec):
        """
        Takes a sequence of 4 color tuples, builds the color maps, if
        the plot data isn't none will modify the plot colors
        """

        self._colors = color_spec

        self._color_maps = [visualizer_colors.PMIColormap("PMIFriend", color_spec[0]),
                            visualizer_colors.PMIColormap("PMITryst", color_spec[1]),
                            visualizer_colors.PMIColormap("PMIHeadToHead", color_spec[2]),
                            visualizer_colors.PMIColormap("PMIArmsRace", color_spec[3])]

        self.color_mappers = [cm.ScalarMappable(norm=self._normalizer, cmap=self._color_maps[0]),
                              cm.ScalarMappable(norm=self._normalizer, cmap=self._color_maps[1]),
                              cm.ScalarMappable(norm=self._normalizer, cmap=self._color_maps[2]),
                              cm.ScalarMappable(norm=self._normalizer, cmap=self._color_maps[3])]

        self.color_samples = dict()
        self._legend_proxies = []
        for mapper, name in zip(self.color_mappers, self.data.relation_types):
            rgba = mapper.to_rgba(0.7, bytes=True)
            self.color_samples[name] = rgba
            self._legend_proxies.append(mpatches.Patch(color=[i/255 for i in rgba], label=name))

        self._on_color_changed()
        self._mpl.redraw()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号