Code Monkey home page Code Monkey logo

scottplot's Introduction

ScottPlot

ScottPlot is an open-source interactive graphing library for .NET written in C#. It was written to simplify the task of interactively displaying data on a graph that you can left-click-drag to pan and right-click drag to zoom. Although ScottPlot was designed for interactive graphing of large datasets in a GUI environment, its core can generate graphs from within console applications. ScottPlot was loosely inspired by matplotlib for Python.

ScottPlot Cookbook

A quick way to learn what ScottPlot can do is to review the automatically-generated cookbook: https://github.com/swharden/ScottPlot/tree/master/doc/cookbook

ScottPlot User Control for interactive Graphing

The simplest way to use ScottPlot is to drag/drop the ScottPlotUC (user control) onto a Windows Form, then fill it with some data. It will automatically draw the graph and immedaitely be interactive to the mouse (left-click-drag to pan, right-click-drag to zoom).

scottPlotUC1.PlotXY(Xs, Ys); // Make a line graph from double arrays
scottPlotUC1.AxisAuto(); // Auto-scale the axis to fit the data

The animated example above demonstrates this functionality

ScottPlot for Static Graphing (GUI)

If the goal is just to add a graph to a Windows Form, it can simply be rendered onto a picturebox eliminating the need for a special user control. This can be accomplished by interacting with the ScottPlot.Figure class directly which yields customization options and speed performance beyond that of the user control. Extensive examples are in the ScottPlot Cookbook.

var fig = new ScottPlot.Figure(pictureBox1.Width, pictureBox1.Height);
fig.AxisAuto(Xs, Ys);
fig.PlotLines(Xs, Ys);
pictureBox1.Image = fig.Render();

ScottPlot for Static Graphing (Console Application)

The ScottPlot.Figure class is fully functional without a GUI! Anything you can do in a Windows Form you can do from a Console Application (saving to a file rather than rending on a picturebox). All examples in the ScottPlot Cookbook can be used in console applications.

var fig = new ScottPlot.Figure(pictureBox1.Width, pictureBox1.Height);
fig.AxisAuto(Xs, Ys);
fig.PlotLines(Xs, Ys);
fig.Save("demo.png");

Highspeed Graphing of Large Datasets

ScottPlot was written to interactively display data with tens of millions of data points. A good example of this is a one hour WAV file (3600 seconds at 48 kHz = 172.8 million points). Numerous optimizations provide this functionality for signals (a series of evenly-spaced data points). Rather than graph two double arrays (Xs and Ys), use ScottPlot's signal graphing methods. Additional options (like like X and Y offset) are demonstrated in the ScottPlot cookbook

ScottPlotUC1.PlotSignal(Ys); // optimized to plot millions of points in real time

Compiled Demos

Compiled (EXE) demos are available for download in the /demos/ folder. They are a good way to test-out what ScottPlot can do without having to download the source code or learn about the API. For non-interactive demos suitable for console applications, check out the ScottPlot cookbook

Installing ScottPlot

  • Download: Get the latest ScottPlot (ZIP) from this page

  • Add Project: Right-click your solution, add, Existing Project, and select /src/ScottPlot/ScottPlot.csproj

  • Add Reference: Right-click your project, Add, Reference, then under Projects select ScottPlot

  • Build: Right-click ScottPlot (in the solution explorer) and select build

Once installed, drag/drop the ScottPlotUC onto your Windows Form and give it data! It will respond to the mouse immediately.

Once a ScottPlotUC is in your form, you can add data to it using the following code. It makes most sense to drop a button on your form, and call this code when the button is clicked:

double[] x = new double[] { 1, 2, 3, 4, 5 };
double[] y = new double[] { 5, 1, 7, 2, 5 };
scottPlotUC1.PlotXY(x, y);
scottPlotUC1.AxisAuto();

Class Diagram

License

ScottPlot uses the MIT License, so use it in whatever you want!

scottplot's People

Contributors

swharden avatar

Watchers

 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.