Giter Site home page Giter Site logo

imhshen / matplotlibcs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itglobal/matplotlibcs

0.0 0.0 0.0 511 KB

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

License: MIT License

C# 66.81% Python 22.92% PowerShell 10.26%

matplotlibcs's Introduction

MatplotlibCS

Build status NuGet

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 paths
var matplotlibCs = new MatplotlibCS.MatplotlibCS(pythonExePath, dasPlotPyPath);

var figure = new Figure(1, 1)
{
    FileName = "ExampleSin.png",
    OnlySaveImage = true,
    DPI = 150,
    Subplots =
    {
        new Axes(1, "The X axis", "The Y axis")
        {
            Title = "Sin(x), Sin(2x), VLines, HLines, Annotations",
            Grid = new Grid()
            {
                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 =
            {
                new Line2D("Sin")
                {
                    X = X.ToList(),
                    Y = Y1.ToList(),
                    LineStyle = LineStyle.Dashed
                },

                new Line2D("Sin 2x")
                {
                    X = X.ToList(),
                    Y = Y2.ToList(),
                    LineStyle = LineStyle.Solid,
                    LineWidth = 0.5f,
                    Color = Color.Green,
                    Markevery = 5,
                    MarkerSize = 10,
                    Marker = Marker.Circle
                },

                new Text("Text annotation", 4.5, 0.76)
                {
                    FontSize = 17
                },

                new Annotation("Arrow text annotation", 0.5, -0.7, 3, 0)
                {
                    Color = Color.Blue
                },

                new Vline("vert line", 3.0, -1, 1),
                new Hline("hrzt line", new[] {0.1, 0.25, 0.375}, 0, 5) {LineStyle = LineStyle.Dashed, Color = Color.Magenta}
            }
        }

    }
};

var t = matplotlibCs.BuildFigure(figure);
t.Wait();

matplotlibcs's People

Contributors

plkn avatar linusg avatar kapitanov avatar oceania2018 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.