If I plot this data using SYSTAT application, it looks like the following:
In ChatGPT, it looks like the following:
However, when I plot it using my C# application, it looks like the following:
Can you tell me what I am doing wrong?
N.B. The C# source code is high-level abstracted source code.
Residue ,Density ,Tau0
10,0.001,21.937
10,0.001,22.04
10,0.001,22.032
10,0.001,21.962
10,0.001,21.845
10,0.001,21.929
10,0.001,21.794
10,0.001,21.918
10,0.001,21.877
10,0.001,21.81
10,0.001,21.832
10,0.001,21.872
10,0.001,21.813
10,0.001,21.608
10,0.001,21.679
10,0.005,22.067
10,0.005,22.037
10,0.005,21.906
10,0.005,21.941
10,0.005,21.964
10,0.005,21.871
10,0.005,21.938
10,0.005,21.918
10,0.005,21.941
10,0.005,21.752
10,0.005,21.766
10,0.005,21.821
10,0.005,21.757
10,0.005,21.699
10,0.005,21.776
10,0.01,22.231
10,0.01,22.228
10,0.01,22.116
10,0.01,22.131
10,0.01,22.166
10,0.01,22.155
10,0.01,21.951
10,0.01,22.003
10,0.01,21.996
10,0.01,22.126
10,0.01,21.981
10,0.01,21.913
10,0.01,21.984
10,0.01,21.947
10,0.01,21.889
15,0.001,55.011
15,0.001,54.892
15,0.001,54.325
15,0.001,54.349
15,0.001,54.554
15,0.001,54.288
15,0.001,54.213
15,0.001,53.985
15,0.001,54.296
15,0.001,54.29
15,0.001,54.187
15,0.001,53.237
15,0.001,53.908
15,0.001,53.524
15,0.001,52.545
15,0.005,55.073
15,0.005,55.296
15,0.005,55.072
15,0.005,54.901
15,0.005,54.969
15,0.005,54.625
15,0.005,54.299
15,0.005,53.906
15,0.005,54.336
15,0.005,53.949
15,0.005,54.12
15,0.005,54.243
15,0.005,53.788
15,0.005,53.831
15,0.005,53.746
15,0.01,55.233
15,0.01,55.165
15,0.01,55.057
15,0.01,54.919
15,0.01,54.849
15,0.01,55.066
15,0.01,55.113
15,0.01,54.624
15,0.01,54.419
15,0.01,54.389
15,0.01,54.075
15,0.01,54.335
15,0.01,53.77
15,0.01,54.248
15,0.01,53.563
25,0.001,164.724
25,0.001,164.99
25,0.001,163.518
25,0.001,164.708
25,0.001,162.769
25,0.001,162.927
25,0.001,162.678
25,0.001,163.869
25,0.001,162.71
25,0.001,161.045
25,0.001,161.379
25,0.001,161.428
25,0.001,161.531
25,0.001,159.493
25,0.001,160.823
25,0.005,167.892
25,0.005,166.525
25,0.005,165.384
25,0.005,164.054
25,0.005,163.825
25,0.005,163.319
25,0.005,161.626
25,0.005,161.139
25,0.005,158.917
25,0.005,160.506
25,0.005,161.778
25,0.005,160.07
25,0.005,159.091
25,0.005,160.715
25,0.005,157.838
25,0.01,167.243
25,0.01,166.138
25,0.01,164.303
25,0.01,167.051
25,0.01,164.707
25,0.01,163.833
25,0.01,164.682
25,0.01,163.755
25,0.01,163.913
25,0.01,162.615
25,0.01,163.848
25,0.01,162.233
25,0.01,160.745
25,0.01,163.592
25,0.01,159.967
using SikorskiLibMemoryLess;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace NversusTauPlotFromCSVNamespace
{
public class CallBackClass
{
public static void Run()
{
try
{
Command actualImageCommand = CommandParserForXml.GetActualCommand("--image_size");
if (actualImageCommand == null || actualImageCommand.DefaultArguments.Count < 2)
{
throw new ArgumentException("Invalid image size command.");
}
int imageWidth = Convert.ToInt32(actualImageCommand.DefaultArguments[0]);
int imageHeight = Convert.ToInt32(actualImageCommand.DefaultArguments[1]);
DataPlotter plotter = new DataPlotter
{
ImageTitle = "Density vs. relaxation time (3D vector case)",
XAxisTitle = "d (density)",
YAxisTitle = "τ0 (relaxation time)",
IsLogY = false,
IsLogX = true,
IsSymbolVisible = true,
IsLegendVisible = true
};
Command outputDirCommand = CommandParserForXml.GetActualCommand("--output");
if (outputDirCommand == null || outputDirCommand.DefaultArguments.Count < 2)
{
throw new ArgumentException("Invalid output directory command.");
}
string outputDir = outputDirCommand.DefaultArguments[0];
string outputFileName = outputDirCommand.DefaultArguments[1];
Command actualFileCommand = CommandParserForXml.GetActualCommand("--input");
if (actualFileCommand == null || actualFileCommand.DefaultArguments.Count < 2)
{
throw new ArgumentException("Invalid input file command.");
}
string inputFilePath = actualFileCommand.DefaultArguments[0];
string chainLengths = actualFileCommand.DefaultArguments[1];
var csv = FileReaderMemoryLess.ReadCSV(inputFilePath);
if (csv == null || csv.Count() == 0)
{
throw new ArgumentException("CSV file is empty or invalid.");
}
var array = ConvertHelper.ToDoubleArray(chainLengths);
List<double> lengthList = new List<double>(array);
ListPairsMemoryLess listPairs = new ListPairsMemoryLess();
foreach (var length in lengthList)
{
List<double> xList = new List<double>();
List<double> yList = new List<double>();
for (int i = 1; i < csv.Count(); i++) // Skip header row
{
try
{
List<string> columns = csv.ElementAt(i);
double residueLength = Convert.ToDouble(columns[0]);
double density = Convert.ToDouble(columns[3]); // Density column
double tao0 = Convert.ToDouble(columns[6]); // Tau0 column
if (residueLength == length)
{
xList.Add(density);
yList.Add(tao0);
}
}
catch (Exception ex)
{
Console.WriteLine($"Error parsing line {i}: {ex.Message}");
}
}
listPairs.Add($"{length}", xList, yList);
//listPairs.SortByXList(); // Sort after adding the pairs
plotter.AddCurve($"N = {length}", xList, yList, UniqueColors.GetNextColor());
Console.WriteLine($"N:{length}, xLen:{xList.Count}, yLen:{yList.Count}");
}
Console.WriteLine("Saving plot");
plotter.SavePlot(outputDir, $"{outputFileName}.png");
Console.WriteLine($"Plot saved in {outputDir}");
plotter.ShowDialog();
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
Console.WriteLine(ex.StackTrace);
}
ConsoleUtils.Wait();
}
}
}