convert 2 arrays into a matrix in python

84 Views Asked by At

I have a coordinates file which I read into a matrix in python. I want to create a delaunay triangulation and plot it with the coordinates joined together with lines. I have the following code which creates the delaunay but I am unsure how to plot it. Any help would be greatly appreciated. The code is as follows:

from matplotlib.pyplot import scatter
import numpy as np
import itertools 

f2 = open('coordinates.txt')
lines = f2.read()
sLines = lines.split('\n')
sLines = sLines[0:-1]

points = []
for lines in sLines:
    points.append(lines.split())

from scipy.spatial import Delaunay
tri = Delaunay(points)

The coordinates file is as follows:

0.73452853     0.00000000
0.00000000     0.00000000
0.42535691     0.18628529
0.62959588     0.00000000
0.52466324     0.00000000
0.41973059     0.00000000
0.31479794     0.00000000
0.20986529     0.00000000
0.10493265     0.00000000
1

There are 1 best solutions below

0
c. leather On

Take a look at the the scipy docs for Delaunay, which includes an example of how to plot the tessellation.