public static void Main(string[] args) { Storage(); // generate data for plotting const double sineFactor = 0.012585; const int exampleCount = 1000; var phaseOffset = 125; var x0 = new double[exampleCount]; var y0 = new double[exampleCount]; for (var j = 0; j < exampleCount; j++) { x0[j] = j; y0[j] = (double)(System.Math.Sin(sineFactor * (j + phaseOffset)) * 1); } var x1 = new double[exampleCount]; var y1 = new double[exampleCount]; phaseOffset = 250; for (var j = 0; j < exampleCount; j++) { x1[j] = j; y1[j] = (double)(System.Math.Sin(sineFactor * (j + phaseOffset)) * 1); } var x2 = new double[exampleCount]; var y2 = new double[exampleCount]; phaseOffset = 375; for (var j = 0; j < exampleCount; j++) { x2[j] = j; y2[j] = (double)(System.Math.Sin(sineFactor * (j + phaseOffset)) * 1); } var x3 = new double[exampleCount]; var y3 = new double[exampleCount]; phaseOffset = 500; for (var j = 0; j < exampleCount; j++) { x3[j] = j; y3[j] = (double)(System.Math.Sin(sineFactor * (j + phaseOffset)) * 1); } // create PLplot object var pl = new PLStream(); // use SVG backend and write to SineWaves.svg in current directory if (args.Length == 1 && args[0] == "svg") { pl.sdev("svg"); pl.sfnam("SineWaves.svg"); } else { pl.sdev("pngcairo"); pl.sfnam("SineWaves.png"); } // use white background with black foreground pl.spal0("cmap0_alternate.pal"); // Initialize plplot pl.init(); // set axis limits const int xMin = 0; const int xMax = 1000; const int yMin = -1; const int yMax = 1; pl.env(xMin, xMax, yMin, yMax, AxesScale.Independent, AxisBox.BoxTicksLabelsAxes); // Set scaling for mail title text 125% size of default pl.schr(0, 1.25); // The main title pl.lab("X", "Y", "PLplot demo of four sine waves"); // plot using different colors // see http://plplot.sourceforge.net/examples.php?demo=02 for palette indices pl.col0(9); pl.line(x0, y0); pl.col0(1); pl.line(x1, y1); pl.col0(2); pl.line(x2, y2); pl.col0(4); pl.line(x3, y3); // end page (writes output to disk) pl.eop(); // output version pl.gver(out var verText); Console.WriteLine("PLplot version " + verText); ////////histogram///////////////////// double[] y00 = { 5.0, 15.0, 12.0, 24.0, 28.0, 30.0, 20.0, 8.0, 12.0, 3.0 }; double[] pos = { 0.0, 0.25, 0.5, 0.75, 1.0 }; double[] red = { 0.0, 0.25, 0.5, 1.0, 1.0 }; double[] green = { 1.0, 0.5, 0.5, 0.5, 1.0 }; double[] blue = { 1.0, 1.0, 0.5, 0.25, 0.0 }; PLStream pls = new PLStream(); pls.sdev("pngcairo"); pls.sfnam("Histogram.png"); pls.spal0("cmap0_alternate.pal"); pls.init(); pls.adv(0); pls.vsta(); pls.wind(1980.0, 1990.0, 0.0, 35.0); pls.box("bc", 1.0, 0, "bcnv", 10.0, 0); pls.col0(2); pls.lab("Year", "Widget Sales (millions)", "#frPLplot Example 12"); for (int i = 0; i < 10; i++) { // pls.col0(i + 1); pls.col1(i / 9.0); pls.psty(0); double[] x = new double[4]; double[] y = new double[4]; x[0] = 1980.0 + i; y[0] = 0.0; x[1] = 1980.0 + i; y[1] = y00[i]; x[2] = 1980.0 + i + 1.0; y[2] = y00[i]; x[3] = 1980.0 + i + 1.0; y[3] = 0.0; pls.fill(x, y); pls.col0(1); pls.lsty(LineStyle.Continuous); pls.line(x, y); // sprintf(string, "%.0f", y0[i]); String text = ((int)(y00[i] + 0.5)).ToString(); pls.ptex((1980.0 + i + .5), (y00[i] + 1.0), 1.0, 0.0, .5, text); // sprintf(string, "%d", 1980 + i); String text1 = (1980 + i).ToString(); pls.mtex("b", 1.0, ((i + 1) * .1 - .05), 0.5, text1); } pls.eop(); Console.ReadLine(); }
public string generateNNGraph(string matrixRef, int NumberInputsNodes, int NumberHiddenNodes, int NumberOutputNodes, int NumberOfEpochs, double LearningRate_eta, string title, int oneCol, string oneLab, int twoCol, string twoLab, string fileName) { var matrixComp = Value(matrixRef); if (matrixComp.GetType() == typeof(string)) { return("Could not find variable " + matrixRef); } MatrixData _graphData = (MatrixData)matrixComp; double[] x = _graphData.GetColumnCopy <double>(0); double[] y = _graphData.GetColumnCopy <double>(1); double[] y1 = _graphData.GetColumnCopy <double>(2); double xMax = _graphData.Max(0); var plot = new PLStream(); plot.width(1); plot.sdev("svg"); plot.sfnam(fileName + ".svg"); plot.scolbg(255, 255, 255); plot.init(); plot.env(0, xMax, 0, 105, AxesScale.Independent, AxisBox.BoxTicksLabelsAxes); Dictionary <int, string> cols = new Dictionary <int, string>(); cols.Add(0, "black"); cols.Add(1, "red"); cols.Add(2, "yellow"); cols.Add(3, "green"); cols.Add(4, "aquamarine"); cols.Add(5, "pink"); cols.Add(6, "wheat"); cols.Add(7, "grey"); cols.Add(8, "brown"); cols.Add(9, "blue"); cols.Add(10, "BlueViolet"); cols.Add(11, "cyan"); cols.Add(12, "turquoise"); cols.Add(13, "magenta"); cols.Add(14, "salmon"); cols.Add(15, "white"); plot.col0(1); plot.lab("Epoch", "Accuracy %", title); plot.ptex(xMax - 10, 25, 1.0, 0, 1, "Input Nodes: " + NumberInputsNodes); plot.ptex(xMax - 10, 20, 1.0, 0, 1, "Hidden Nodes: " + NumberHiddenNodes); plot.ptex(xMax - 10, 15, 1.0, 0, 1, "Output Nodes: " + NumberOutputNodes); plot.ptex(xMax - 10, 10, 1.0, 0, 1, "Epochs: " + NumberOfEpochs); plot.ptex(xMax - 10, 5, 1.0, 0, 1, "Learning Rate: " + LearningRate_eta); plot.col0(1); plot.col0(oneCol); plot.line(x, y); plot.ptex(xMax - 10, 35, 1.0, 0, 1, cols[oneCol] + ": " + oneLab); plot.col0(oneCol); plot.col0(twoCol); plot.line(x, y1); plot.ptex(xMax - 10, 30, 1.0, 0, 1, cols[twoCol] + ": " + twoLab); plot.col0(twoCol); plot.eop(); return(Directory.GetCurrentDirectory() + "\\" + fileName + ".svg"); }
public string GenerateGraph() { double[] x = _graphData.GetColumnCopy <double>(0); double[] y = _graphData.GetColumnCopy <double>(1); double[] y1 = _graphData.GetColumnCopy <double>(2); double xMax = _graphData.Max(0); //double yMax = _graphData.Max(1); //yMax = (_graphData.Max(2) > yMax)? _graphData.Max(2) : yMax; //double yMin = _graphData.Min(1); //yMin = (_graphData.Min(2) < yMin)? _graphData.Min(2): yMin; var plot = new PLStream(); plot.width(1); plot.sdev("svg"); plot.sfnam("Test.svg"); plot.scolbg(255, 255, 255); plot.init(); plot.env(0, xMax, 0, 105, AxesScale.Independent, AxisBox.BoxTicksLabelsAxes); //####### PLPlot colour guide: //0 black (default background) //1 red (default foreground) //2 yellow //3 green //4 aquamarine //5 pink //6 wheat //7 grey //8 brown //9 blue //10 BlueViolet //11 cyan //12 turquoise //13 magenta //14 salmon //15 white plot.col0(1); if (!(_testingData == null)) { plot.lab("Epoch", "Accuracy %", "Test vs Train Accuracy"); } else { plot.lab("Epoch", "Accuracy %", "Test vs Val Accuracy"); } plot.ptex(xMax - 10, 25, 1.0, 0, 1, "Input Nodes: " + NumberInputsNodes); plot.ptex(xMax - 10, 20, 1.0, 0, 1, "Hidden Nodes: " + NumberHiddenNodes); plot.ptex(xMax - 10, 15, 1.0, 0, 1, "Output Nodes: " + NumberOutputNodes); plot.ptex(xMax - 10, 10, 1.0, 0, 1, "Epochs: " + NumberOfEpochs); plot.ptex(xMax - 10, 5, 1.0, 0, 1, "Learning Rate: " + LearningRate_eta); plot.col0(1); plot.col0(9); plot.line(x, y); plot.ptex(xMax - 10, 35, 1.0, 0, 1, "Blue: Train"); plot.col0(9); plot.col0(3); plot.line(x, y1); if (!(_testingData == null)) { plot.ptex(xMax - 10, 30, 1.0, 0, 1, "Green: Test"); } else { plot.ptex(xMax - 10, 30, 1.0, 0, 1, "Green: Val"); } plot.col0(3); plot.eop(); return("Saved \"Test.svg\""); }