Giter VIP home page Giter VIP logo

custommatplot's Introduction

CustomMatPlot

Plot library for the JUCE Framework

CustomMatPlot (CMP) is a plotting library for C++. It provides an API for embedding plot components into applications using the JUCE framework. The plot component is easy to integrate and is customizable using the included lookandfeel class.

Image Image

Note: I'm not a senior developer so there may be several design flaws.

Table of Content

Features

CMP implements many of the same features that exist in Matplotlib. Below is the feature list of CMP:

  • Axis scaling: Linear and logarithmic.
  • Customizable view using the lookandfeel class.
  • Legend.
  • Zoom.
  • Trace.
  • Fill area between two graphs.
  • Axis labels.
  • Ticks and Tick-labels.
  • Grids and tiny grids.
  • Markers: Star, triangles, square etc.
  • Custom stroke path.
  • Callback for every visible data point.
  • Callback for tace points.
  • Two different downsampler levels.
  • Move points in the garph with mouse.
  • Customizable userinput mapping using lookandfeel class.

Image

Requirements

  • Compiler that supports C++17
  • CMake 3.12

Controls

The CMP compontent implements MouseEvents to interact with the plot using the mouse. Below is a list with the default added mouse commands which can be overrided using a custom lookandfeel class (see "move_graph_points" example):

  1. Left click drag anywhere in the graph area to zoom into the plot. The zoom area is displayed as traced lined rectangle.
  2. Right click to zoom out to home.
  3. Double-click to add a trace-point to the graph lines closest to the mouse pointer.
  4. Double-click on a trace-point to remove it.
  5. Drag the trace point to move it along the graph-line.
  6. Move the trace point label by dragging it.
  7. Move the legend to by dragging it.
  8. Move graph points.
  9. Panning for linear scaling
  10. #TODO: Panning for logarithmic scaling

LookAndFeel

Customize the plot to your liking by overriding the lookandfeel functions. See the lookandfeel example.

Image

Graph line attributes

Use the graph line attributes to change the appearance of the graph lines. See custom_graph_attributes example.

Image

Examples

The examples can be built using the following commands:

# Clone repository
git clone https://github.com/franshej/CustomMatPlot.git

cd CustomMatPlot

# Update submodules
git submodule update --init

mkdir build
cd build

# Config & build
cmake ../ -DCMP_BUILD_EXAMPLES=ON
make -j4

Realtime frequency response example app

An example app plotting the frequency response of the incoming left and right audio signals can be seen here: Realtime plot example

Image

Tests

To make it more convenient to write new tests the CMP library implements tests macros similar to the macros in google tests.

The following example below will plot a ramp of 10 values from 0-9:

TEST(ramp, non_real_time) {
  ADD_PLOT;

  std::vector<float> y_test_data(10u);
  std::iota(y_test_data.begin(), y_test_data.end(), 0.0f);

  PLOT_Y({y_test_data});
}

Image

License

The MIT License (MIT)

Copyright (c) 2017-2022 Frans Rosencrantz

Free Software, Hell Yeah!

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.