I am fairly new to Python, and I have been tasked to make a script that creates a plot of a Delaunay triangulation. I have successfully done so, but I need the colors of the points to change based on how many neighbors the plots have. I have a function that defines the number of neighbors and puts all points into a dictionary with the number of neighbors as the key. However, I don't know how to apply that dictionary to my plot - is there a specific function where you can take the plot created with triplot and change the colors based on an outside dictionary? Here is my code so far:
from curved_analysis import read_xyz, read_nfo, num_neighbors
from scipy.spatial import Delaunay
import matplotlib.tri as mtri
import numpy as np
import matplotlib.pyplot as plt
coords = np.array(read_xyz("traj0.xyz"))
for k in range(coords.shape[0]):
points = coords[k]
tri = Delaunay(points[:, :2], qhull_options=('Qz'))
neigh = num_neighbors(tri)
for key in neigh:
if key <=5:
plt.triplot(neigh[key], color = 'green')
if key == 6:
plt.triplot(neigh[key], color = 'red')
if key >= 7:
plt.triplot(neigh[key], color = 'yellow')
plt.triplot(points[:,0], points[:,1], tri.simplices)
plt.plot(points[:,0], points[:,1], 'o')
plt.show()
Thank you for your help!

