I am using matplotlib 1.15.1 and I am trying to create diagrams like this:

Ellipses have the size of corrections and are drawn with central coordinates, width, height and angle (provided from the outside): I have no idea what their equotions are.
g_ell_center = (0.8882, 0.8882) g_ell_width = 0.36401857095483 g_ell_height = 0.16928136341606 g_ellipse = patches.Ellipse(g_ell_center, g_ell_width, g_ell_height, angle=angle, fill=False, edgecolor='green', linewidth=2)
These ellipses should mark normal and semi-normal data on my plot. Then I have an array of ~ 500 points that should be colored according to the ellipse to which they belong. So I tried to check each point using the contains_point method:
colors_array = [] colors_scheme = ['green', 'yellow', 'black'] for point in points_array: if g_ellipse.contains_point(point, radius=0): colors_array.append(0) elif y_ellipse.contains_point(point, radius=0): colors_array.append(1) else: colors_array.append(2)
Finally, dots are drawn:
plt.scatter(x_array, y_array, s=10, c=[colors_scheme[x] for x in colors_array], edgecolor="k", linewidths=0.3)
But contains_point is very slow! It worked for 5 minutes for a 300-point chart, and I have to generate thousands of them in parallel. Maybe there is a faster approach? Postscript The whole project is related to matplotlib, I can not use other libraries.