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")
评论列表
文章目录