Skip to content

Qnubo-Tech/SharpPlot

SharpPlot

SharpPlot

Unit tests Documentation Status License Open Source Love svg1

forthebadge ForTheBadge built-by-developers

Welcome

#Plot (so-called SharpPlot) is a class-library devoted to bring live graph representation capabilities to .Net. The library is a human-friendly wrapper for the widely-known GNUplot software. The fundamental idea behind this project is to bring to .NET core the easiness provided by other libraries in the Python's community, e.g., MatPlotLib. The library is provides the capability of live graph plots whilst running an executable solution, which is of fundamental importance in scientific and/or numerical software.

Getting started

The library is available via nuget. Hence, the typical rules for installing a nuget-package in your project/solution applies, i.e.:

> dotnet add package

However, for the sake of clarity, we provide a simple-project example in the next paragraph which will let you understand the standard way of interacting with the library.

Simple project

Let's get started by creating a working directory (e.g., in our desktop):

(HOME)$ mkdir ~/Desktop/working-directory
(HOME)$ cd ~/Desktop/working-directory 

Now, let's create a simple console project inside:

(~/Desktop/working-directory)$ dotnet new console --output graph

The template "Console Application" was created successfully.
Processing post-creation actions...

Running 'dotnet restore' on graph/graph.csproj...
  Restore completed in 152.26 ms for /Users/YOURUSERNAME/Desktop/test-csharp/graph/graph.csproj.
Restore succeeded.

Now we're going to add the library to the project by utilising dotnet SDK:

(~/Desktop/working-directory)$ cd graph
(~/Desktop/working-directory)$ dotnet add package SharpPlot

Go and edit the Program.cs file you'll have in the folder you're at (supposedly ~/Destop/working-directory/graph/) and edit it to get the following:

using System;
using System.Linq;
using SharpPlot;
using SharpPlot.Canvas.Figure;

namespace graph
{
    class Program
    {
        static void Main(string[] args)
        {
            Gnuplot.Start();
            var x = Enumerable.Range(-100, 201).Select(z=>z*0.025*Math.PI).ToArray();
            var sinX = x.Select(Math.Sin).ToArray();
            var data = new DataPoints(x, sinX);
            var (id, fig) = Gnuplot.Plot<Line>(data, "First Example: sin(x)");
            Gnuplot.Show();
            Gnuplot.Wait();
        }
    }
}

Save the file, and run the following command in the terminal:

(~/Desktop/working-directory/graph)$ dotnet run
Press any key + Enter to continue...

and you should get your first floating graph example with #Plot, congratulations!

simple-project

Requirements

#Plot is a wrapper of gnuplot, which is why we list it as one of the main dependencies. You only need to have it installed in your OS, and #Plot will know where to look for it. Therefore, the list of main dependencies is as follows:

Main features

We think the best way to learn is by example and documentation. For this reason, we have prepared a set of examples which are enclosed in a different solution under the Examples folder. There you will find different small projects that will help you understand the use of #Plot:

  • 001-GettingStarted: The example we have followed in the previous section, with a little README file, and a Jupyter notebook!

Authors

Contributing

To have a better understanding on how to make contributions, please read the CONTRIBUTING file. Our style of code adheres to Google's standards (google-styleguide). We want to keep the source consistent, readable and easy to merge. For this reason we use rigid coding style and we expect all contributors to conform this guidelines. Please, use .clang-format to check your formatting.

License

This project is licensed under the 3-Clause BSD License - see the LICENSE file for details.

About

SharPlot: A GNUPlot wrapper for .Net Core

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages