def plot_contour(self, xv, yv, cost_grid):
"""
Function constructs contour lines
"""
contour = Contour(xv, yv, cost_grid)
contour_lines = contour.contours(
np.linspace(np.min(cost_grid), np.max(cost_grid), 20))
series = []
count = 0
for key, value in contour_lines.items():
for line in value:
if len(line) > 3:
tck, u = splprep(np.array(line).T, u=None, s=0.0, per=0)
u_new = np.linspace(u.min(), u.max(), 100)
x_new, y_new = splev(u_new, tck, der=0)
interpol_line = np.c_[x_new, y_new]
else:
interpol_line = line
series.append(dict(data=interpol_line,
color=self.contour_color,
type="spline",
lineWidth=0.5,
marker=dict(enabled=False),
name="%g" % round(key, 2),
enableMouseTracking=False
))
count += 1
return series
评论列表
文章目录