Skip to content

A tiny utility for utilizing Matplotlib Python charting library from C#.

License

Notifications You must be signed in to change notification settings

ITGlobal/MatplotlibCS

Repository files navigation

MatplotlibCS

Build statusNuGet

A tiny library for utilizing Matplotlib Python charting library from C#. The general process is this:

How to install

PS D:\MatplotlibCS> pip install flask PS D:\MatplotlibCS> python -mpip install matplotlib 
PM> Install-Package MatplotlibCS 

Basic usage

  1. You create an instance of the class Figure and initialize it's properties with relative data. This instance describes everything you want to see on the figure.
  2. You initialize MatplotlibCS class instance. You need to specify a path to python.exe and matplotlib_cs.py in constructor.
  3. Call MatplotlibCS instance BuildFigure method to plot the figure.
  4. Run
PS D:\MatplotlibCS> dotnet .\Examples\bin\Debug\netcoreapp2.1\Examples.dll python .\MatplotlibCS\Python\matplotlib_cs.py 

Examples

ExampleSin

// Init engine with right pathsvarmatplotlibCs=newMatplotlibCS.MatplotlibCS(pythonExePath,dasPlotPyPath);varfigure=newFigure(1,1){FileName="ExampleSin.png",OnlySaveImage=true,DPI=150,Subplots={newAxes(1,"The X axis","The Y axis"){Title="Sin(x), Sin(2x), VLines, HLines, Annotations",Grid=newGrid(){MinorAlpha=0.2,MajorAlpha=1.0,XMajorTicks=new[]{0.0,7.6,0.5},YMajorTicks=new[]{-1,2.5,0.25},XMinorTicks=new[]{0.0,7.25,0.25},YMinorTicks=new[]{-1,2.5,0.125}},PlotItems={newLine2D("Sin"){X=X.ToList(),Y=Y1.ToList(),LineStyle=LineStyle.Dashed},newLine2D("Sin 2x"){X=X.ToList(),Y=Y2.ToList(),LineStyle=LineStyle.Solid,LineWidth=0.5f,Color=Color.Green,Markevery=5,MarkerSize=10,Marker=Marker.Circle},newText("Text annotation",4.5,0.76){FontSize=17},newAnnotation("Arrow text annotation",0.5,-0.7,3,0){Color=Color.Blue},newVline("vert line",3.0,-1,1),newHline("hrzt line",new[]{0.1,0.25,0.375},0,5){LineStyle=LineStyle.Dashed,Color=Color.Magenta}}}}};vart=matplotlibCs.BuildFigure(figure);t.Wait();

About

A tiny utility for utilizing Matplotlib Python charting library from C#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •