matplotlib legend according to color code example
Example: legend text color matplotlib
import matplotlib.pyplot as plt
l = plt.legend()
for text in l.get_texts():
text.set_color("red")
import matplotlib.pyplot as plt
l = plt.legend()
for text in l.get_texts():
text.set_color("red")