# Revision history [back]

It seems that the color_by_label option from the plot function just uses as many colors as labels from the sage.plot.colors.rainbow function. That is, the color is not taken from the labels themselves but from the rainbow function.

Maybe the following example can help you obtain the plot settings you want.

g=graphs.IcosahedralGraph()
for e in g.edges():
g.set_edge_label(e[0],e[1],1 if e[0]%2 or e[1]%2 else 2)
d={1: "blue", 2: "green"} # _color_by_label will use this to map labels to colors
g.plot(edge_colors=g._color_by_label(d))


This produced the following output.