Created
May 20, 2022 17:32
-
-
Save bradmartin333/2d9adbf0a470fd9977704455e7ca4247 to your computer and use it in GitHub Desktop.
X_Y.png filenames to scatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
namespace picPosScatter | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
List<System.Drawing.PointF> points = new List<System.Drawing.PointF>(); | |
string[] files = Directory.GetFiles(@"C:\Users\delta\Desktop\Images"); | |
foreach (string file in files) | |
{ | |
string clean = file.Replace(".png", "").Split('\\').Last(); | |
string[] cols = clean.Split('_'); | |
points.Add(new System.Drawing.PointF(float.Parse(cols[0]), float.Parse(cols[1]))); | |
} | |
var plt = new ScottPlot.Plot(600, 400); | |
plt.Grid(false); | |
double[] xs = points.Select(x => (double)x.X).ToArray(); | |
double[] ys = points.Select(x => (double)x.Y).ToArray(); | |
plt.AddScatter(xs, ys, lineStyle: ScottPlot.LineStyle.None); | |
plt.SaveFig(@"C:\Users\delta\Desktop\fig.png"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment