PMIPlot.py 文件源码

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

项目:Visualization 作者: nwrush 项目源码 文件源码
def _color_plot(self):
        colors = []
        for x, y in zip(self.x_values, self.y_values):
            distance = math.sqrt(x ** 2 + y ** 2)
            if x >= 0 and y >= 0:  # First quadrant, someone has to select zero
                colors.append(self.color_mappers[0].to_rgba(distance))
            elif x < 0 and y > 0:  # Second quadrant
                colors.append(self.color_mappers[1].to_rgba(distance))
            elif x < 0 and y < 0:  # Third quadrant
                colors.append(self.color_mappers[2].to_rgba(distance))
            elif x > 0 and y < 0:  # Fourth quadrant
                colors.append(self.color_mappers[3].to_rgba(distance))
            else:
                logging.error("({x}, {y}) couldn't be mapped onto grid".format(x=x, y=y))
                colors.append((0, 0, 0, 0))
        self.plot_data.set_color(colors)
        self._point_colors = colors

        self.axes.legend(handles=self._legend_proxies, loc="best")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号