flower_sets_plot = {
let non_convex_lines = [
{ x: -1 / 2, y: -1 / 4, set: 1, col: "red" },
{ x: 1 / 4, y: 1 / 8, set: 1, col: "red" },
{ x: 1 / 2, y: 1 / 4, set: 2, col: "red" },
{ x: 9 / 8, y: 9 / 16, set: 2, col: "red" },
{ x: -1 / 2, y: -1 / 16, set: 3, col: "blue" },
{ x: 1 / 4, y: 1 / 32, set: 3, col: "blue" },
{ x: 1 / 2, y: 1 / 16, set: 4, col: "blue" },
{ x: 9 / 8, y: 9 / 64, set: 4, col: "blue" }
];
let flower = [...Array(flower_values.shape[0])].map((d, i) => ({
x: flower_values.get(i, 0),
y: flower_values.get(i, 1),
set: 5,
col: "green"
}));
let mean_points = iteration_pts_flower.map((d) =>
d.reduce((a, b) => [a[0] + b[0], a[1] + b[1]]).map((m) => m / d.length)
);
let trace_red = iterate_flower.includes("individual traces")
? iteration_pts_flower.map((d) => d[0])
: [];
let trace_blue = iterate_flower.includes("individual traces")
? iteration_pts_flower.map((d) => d[1])
: [];
let trace_green = iterate_flower.includes("individual traces")
? iteration_pts_flower.map((d) => d[2])
: [];
return Plot.plot({
x: { axis: false, domain: [-1 / 2, 9 / 8] },
y: { axis: false, domain: [-1 / 4, 1 / 2] },
aspectRatio: 1,
style: { background: "none" },
marks: [
Plot.line([...non_convex_lines, ...flower], {
x: "x",
y: "y",
z: "set",
stroke: "col"
}),
Plot.line(mean_points, {
stroke: "orange"
}),
Plot.line(trace_red, {
stroke: "red",
strokeDasharray: "4 4"
}),
Plot.line(trace_blue, {
stroke: "blue",
strokeDasharray: "4 4"
}),
Plot.line(trace_green, {
stroke: "green",
strokeDasharray: "4 4"
}),
Plot.dot(mean_points, {
fill: "orange",
fillOpacity: 0.5,
r: 10
})
]
});
}