In order to color the areas of a scipy.spatial Voronoi tessellation with respect to an own colorbar I am using the code from here
I want to add some more points (that are independent of the Voronoi tessellation) to the plot. However, only the points outside of the finite regions are being plotted. Any ideas on how to make all of the extra points visible? E.g. only 1 out of 5 points is visible (see code below)
Also, I would like to add a colorbar on the side to see my color scale.
I appreciate any help, thank you!
def plot_voronoi_colour(vor, O):
# @param vor: Voronoi tessellation
# @param O: own color scale
# find min/max values for normalization
minima = min(O)
maxima = max(O)
# normalize chosen colormap
norm = mpl.colors.Normalize(vmin=minima, vmax=maxima, clip=True)
mapper = mpl.cm.ScalarMappable(norm=norm, cmap='viridis')
# plot Voronoi diagram, and fill finite regions with color mapped from speed value
voronoi_plot_2d(vor, show_points=True, show_vertices=False, s=1)
for r in range(len(vor.point_region)):
region = vor.regions[vor.point_region[r]]
if not -1 in region:
polygon = [vor.vertices[i] for i in region]
plt.fill(*zip(*polygon), color=mapper.to_rgba(O[r]))
p2 = [[0,0],[20, 10], [30, 40], [70, 35], [75, 75]]
# [Only [0,0] visible][1]
x, y = zip(*p2)
plt.scatter(x, y, c='y', s=500)