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 ExampleTimeAxis
{
///
/// Chart of sin
///
public static void Run(string pythonExePath, string dasPlotPyPath)
{
#region create test data
const int N = 10;
var X = new double[N];
var Y1 = new double[N];
var Y2 = new double[N];
var x = 0.0;
const double h = 2 * Math.PI / N;
var rnd = new Random();
for (var i = 0; i < N; i++)
{
var y = Math.Sin(x);
X[i] = x;
Y1[i] = y;
y = Math.Sin(2 * x);
Y2[i] = y + rnd.NextDouble() / 10.0;
x += h;
}
#endregion
#region create plot
// init engine with right paths
var matplotlibCs = new MatplotlibCS.MatplotlibCS(pythonExePath, dasPlotPyPath);
var timeTicks = new List();
timeTicks.Add(DateTime.Now);
var xMajorTicks = new List();
xMajorTicks.Add(0);
for (var i = 1; i < N; i++)
{
xMajorTicks.Add(i);
timeTicks.Add(timeTicks[i - 1] + new TimeSpan(0, rnd.Next(1, 10), 0, 0));
}
var figure = new Figure(1, 1)
{
FileName = "ExampleTimeAxis.png",
OnlySaveImage = true,
DPI = 150,
Subplots =
{
new Axes(1, "Time", "Value")
{
Title = "Time Axis Example",
LegendBorder = false,
Grid = new Grid()
{
MinorAlpha = 0.2,
MajorAlpha = 1.0,
XTimeTicks = timeTicks.Cast