diff --git a/KMeansGui/App.axaml b/KMeansGui/App.axaml
index 39b558c..0de2236 100644
--- a/KMeansGui/App.axaml
+++ b/KMeansGui/App.axaml
@@ -2,9 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="KMeansGui.App">
-
+
-
\ No newline at end of file
diff --git a/KMeansGui/KMeansGui.csproj b/KMeansGui/KMeansGui.csproj
index e869fcc..39d7b1e 100644
--- a/KMeansGui/KMeansGui.csproj
+++ b/KMeansGui/KMeansGui.csproj
@@ -8,12 +8,13 @@
-
-
+
+
-
-
-
+
+
+
+
diff --git a/KMeansGui/Shell/ShellView.axaml b/KMeansGui/Shell/ShellView.axaml
index 6b64df7..3acfd88 100644
--- a/KMeansGui/Shell/ShellView.axaml
+++ b/KMeansGui/Shell/ShellView.axaml
@@ -1,28 +1,45 @@
-
+
-
-
-
+
+
+
-
+
+
\ No newline at end of file
diff --git a/src/Helper.cs b/src/Helper.cs
index aa6a3ae..f3f2507 100644
--- a/src/Helper.cs
+++ b/src/Helper.cs
@@ -1,7 +1,8 @@
using ScottPlot;
using System.Diagnostics;
-using System.Drawing;
using Point = KMeansBase.Point;
+using ScottPlot.Legends;
+using Color = ScottPlot.Color;
namespace kMeans;
@@ -10,24 +11,29 @@ public static class Helper
public static Plot CreatePlot(IEnumerable points, IEnumerable centroids)
{
var plot = new Plot();
- plot.Legend(true, Alignment.UpperRight);
+
+ var legend = new StandardLegend { Alignment = Alignment.UpperRight };
+ plot.Legends.Add(legend);
var colors = new Dictionary();
var colorGroups = points.GroupBy(x => x.ClusterId);
foreach (var clusterGroup in colorGroups)
{
- var color = plot.GetNextColor();
+ var color = plot.Add.NextColor;
colors.Add(clusterGroup.Key, color);
var xs = clusterGroup.Select(p => p.X).ToArray();
var ys = clusterGroup.Select(p => p.Y).ToArray();
- plot.AddScatterPoints(xs, ys, color);
+ plot.Add.Scatter(xs, ys);
}
- const MarkerShape marker = MarkerShape.cross;
+ const MarkerShape marker = MarkerShape.FilledSquare;
const float size = 10f;
foreach (var (x, y, clusterId) in centroids)
{
- var color = colors.TryGetValue(clusterId, out var c) ? c : plot.GetNextColor();
- plot.AddScatterPoints(new[] { x }, new[] { y }, color, size, marker, $"ClusterId: {clusterId}");
+ var color = colors.TryGetValue(clusterId, out var c) ? c : plot.Add.NextColor;
+ var scatter = plot.Add.Scatter(new[] { x }, new[] { y }, color);
+ scatter.MarkerStyle.Size = size;
+ scatter.MarkerStyle.Shape = marker;
+ scatter.Label = $"ClusterId: {clusterId}";
}
return plot;
@@ -35,7 +41,7 @@ public static class Helper
public static void ExportPlot(Plot plot, string path)
{
- plot.SaveFig(path);
+ plot.SavePng(path, 1000, 1000);
}
public static void PreviewPlot(string path)
diff --git a/src/kMeansConsole.csproj b/src/kMeansConsole.csproj
index 9d96a56..7a2ae2d 100644
--- a/src/kMeansConsole.csproj
+++ b/src/kMeansConsole.csproj
@@ -9,7 +9,7 @@
-
+