Repository navigation
Expand file tree
/
Copy pathExampleHistogram.cs
More file actions
104 lines (95 loc) · 3.19 KB
/
Copy pathExampleHistogram.cs
File metadata and controls
104 lines (95 loc) · 3.19 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
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MatplotlibCS;
using MatplotlibCS.PlotItems;
namespace Examples.Plot2D
{
class ExampleHistogram
{
/// <summary>
/// Chart of sin
/// </summary>
public static void Run(string pythonExePath, string dasPlotPyPath)
{
#region create test data
const int N = 1000;
var X = new double[N];
var rnd = new Random();
for (var i = 0; i < N; i++)
X[i] = (rnd.NextDouble()-0.5)*10.0;
#endregion
#region create plot
// init engine with right paths
var matplotlibCs = new MatplotlibCS.MatplotlibCS(pythonExePath, dasPlotPyPath);
var figure = new Figure(2, 2)
{
FileName = "ExampleHistogram.png",
OnlySaveImage = true,
DPI = 150,
Subplots =
{
new Axes(1, "The X axis", "The Y axis")
{
Title = "Hist 1",
ShowLegend = false,
PlotItems =
{
new Histogram("Sin")
{
Y = X.ToList(),
}
}
},
new Axes(2, "The X axis", "The Y axis")
{
Title = "Hist 2",
PlotItems =
{
new Histogram("Sin")
{
Y = X.ToList(),
Color = Color.Black,
Alpha = 0.5,
Range = new []{-1, 1.0}
}
}
},
new Axes(3, "The X axis", "The Y axis")
{
Title = "Hist 3",
PlotItems =
{
new Histogram("Sin")
{
Y = X.ToList(),
Orientation = HistogramOrientation.Horizontal
}
}
},
new Axes(4, "The X axis", "The Y axis")
{
Title = "Hist 4",
PlotItems =
{
new Histogram("Sin")
{
Y = X.ToList(),
Bins = 10,
Color = Color.Red,
Alpha = 0.5,
Range = new []{-1, 1.0},
Normed = true
}
}
},
}
};
var t = matplotlibCs.BuildFigure(figure);
t.Wait();
#endregion
}
}
}