We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I wanna know how to plot the result of the Voronoi partition in Matplotlib and uniquely colourize the individual faces.
Can you show me a example?
The text was updated successfully, but these errors were encountered:
Hi, Due to your question is still open and based on https://stackoverflow.com/questions/20515554/colorize-voronoi-diagram/20678647#20678647 example could be like that:
# python 3.5, pyvoro 1.3.2, linux x64 import matplotlib import matplotlib.pyplot as plt import pyvoro import numpy as np dots_num = 50 colors = np.random.rand(dots_num, 3) # or predefined dots = np.random.rand(dots_num, 2) # make color map (unnecessary for just random colorization) color_map = {tuple(coords):color for coords, color in zip(dots, colors)} cells = pyvoro.compute_2d_voronoi( dots, # point positions, 2D vectors this time. [[0.0, 1.0], [0.0, 1.0]], # box size 2.0 # block size ) # colorize for i, cell in enumerate(cells): polygon = cell['vertices'] plt.fill(*zip(*polygon), color = color_map[tuple(cell['original'])], alpha=0.5) plt.plot(dots[:,0], dots[:,1], 'ko') plt.xlim(-0.1, 1.1) plt.ylim(-0.1, 1.1) plt.show()
Sorry, something went wrong.
No branches or pull requests
Hi,
I wanna know how to plot the result of the Voronoi partition in Matplotlib and uniquely colourize the individual faces.
Can you show me a example?
The text was updated successfully, but these errors were encountered: