I would like to generate an item in the legend for each color in the scatter plot using the values from class_titles
import matplotlib.pyplot as plt
classes = [0, 1, 2, 0, 1, 1, 2]
x = [0, 1, 2, 0, 1.3, 1.5, 2.2]
y = [.5, 1, 2, .9, 1.2, 1.2, 2.1]
class_titles = ['first', 'second', 'third']
plt.scatter(x, y, c=labels, cmap='gist_rainbow')
plt.show()
Is there any way to do this other than:
filtering the X, Y values for each class into 3 separate lists and creating 3 scatter plots
load the color map, figure out the color for each label, and create a custom legend from
Patches