0

I am trying to plot a tuple of polygons(voronoipolys) in a list that is returned by the code below

import matplotlib.pyplot as plt
import pytess
points = [(1,1), (5,5), (3,5), (8,1)]
voronoipolys = pytess.voronoi(points)

plt.plot(voronoipolys)
plt.show()

I am getting the following error message:

ValueError: setting an array element with a sequence.

Thanks for your help

1 Answer 1

2

So an easy solve is to use scipy instead of pytess.

You could do the following:

import matplotlib.pyplot as plt
from scipy.spatial import Voronoi, voronoi_plot_2d

points = [(1,1), (5,5), (3,5), (8,1)]
vor = Voronoi(points)
voronoi_plot_2d(vor)
plt.show()

This will produce the following plot:

enter image description here

The reason you fail to just use plot Is because pytess.voronoi returns a tuple of either point or None and a polygon so you need to construct the plot yourself.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.