I'm trying to plot a delaunay triangulation from a pandas df. I'm hoping to group the points by Time
. At present, I'm getting an error when attempting to plot the point from the first time point.
QhullError: QH6214 qhull input error: not enough points(2) to construct initial simplex (need 6)
While executing: | qhull d Q12 Qt Qc Qz Qbb
Options selected for Qhull 2019.1.r 2019/06/21:
run-id 768388270 delaunay Q12-allow-wide Qtriangulate Qcoplanar-keep
Qz-infinity-point Qbbound-last _pre-merge _zero-centrum Qinterior-keep
_maxoutside 0
It appears it's only passing those two arrays as a single points.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay
df = pd.DataFrame({
'Time' : [1,1,1,1,2,2,2,2],
'A_X' : [5, 5, 6, 6, 4, 3, 3, 4],
'A_Y' : [5, 6, 6, 5, 5, 6, 5, 6],
})
fig, ax = plt.subplots(figsize = (6,6))
ax.set_xlim(0,10)
ax.set_ylim(0,10)
ax.grid(False)
points_x = df.groupby("Time")["A_X"].agg(list).tolist()
points_y = df.groupby("Time")["A_Y"].agg(list).tolist()
points = list(zip(points_x1, points_y1))
tri = Delaunay(points[0])
#plot triangulation
plt.triplot(points[:,0], points[:,1], tri.simplices)
plt.plot(points[:,0], points[:,1], 'o')
from Plot Delaney triangulation grouped by value
No comments:
Post a Comment