Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
98 lines (94 loc) · 3.38 KB
/
Copy pathProgram.cs
File metadata and controls
98 lines (94 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// Program.cs
//
// Author:
// Martin Haesemeyer <m.haesemeyer@gmail.com>
//
// Copyright (c) 2015 Martin Haesemeyer
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using System.Diagnostics;
using System.Threading;
using System.Collections.Generic;
using PythonInterface;
namespace PyPlotTest
{
/// <summary>
/// Command line program to test PyPlotInterface
/// </summary>
class MainClass
{
public static void Main (string[] args)
{
var py = new PyPlotInterface(true,true);
var labels = new PlotDecorators();
labels.Title = "Test of single plot";
labels.XLabel = "X";
labels.YLabel = "Y";
var Plot = py.MakePlotFunction(labels, PyPlotInterface.AxesStyle.dark);
labels.Title = "Test of histogram plot";
labels.YLims = new Tuple<double, double>(0, 1.1);
var Hist = py.MakeHistFunction(labels,true,true);
labels.Title = "Test of series plot";
labels.YLims = new Tuple<double, double>(-5, 5);
labels.ColorCycle = new List<PlotColor>();
labels.ColorCycle.Add(new PlotColor(0.7, 0.4, 0.7));
labels.ColorCycle.Add(new PlotColor());
labels.ColorCycle.Add(new PlotColor(0.7, 0.7, 0.3));
var PlotMulti = py.MakeSeriesPlotFunction(labels);
//create our plot data
int dataSize = 5000;
double[] x = new double[dataSize];
double[] y = new double[dataSize];
double[] y2 = new double[dataSize];
double[] y3 = new double[dataSize];
for (int i = 0; i < dataSize; i++)
{
x[i] = 10.0 / dataSize * i;
y[i] = Math.Sin(x[i]);
y2[i] = Math.Cos(x[i]);
y3[i] = Math.Tan(x[i]);
}
List<double[]> X = new List<double[]>();
X.Add(x);
X.Add(y);
X.Add(x);
X.Add(x);
List<double[]> Y = new List<double[]>();
Y.Add(y);
Y.Add(y2);
Y.Add(y2);
Y.Add(y3);
Console.WriteLine("Plotting");
PlotMulti(X, Y);
Plot(y, x);
string f3 = Hist(y, 20);
Console.WriteLine("Press return to close figure 3");
Console.ReadLine();
py.CloseFigure(f3);
Console.WriteLine("Press return to close remaining figures");
Console.ReadLine();
py.CloseAllFigures();
py.Dispose();
Console.WriteLine("Press return to exit");
Console.ReadLine();
}
}
}