GithubHelp home page GithubHelp logo

ncgraph's Introduction

NCGraph

Python NCurses Grapher Class (terminal plotting library).

Usage

  1. Direct plotting: ncgraph.plot(x, y [,legend]).
  2. Create a figure object with ncgraph.Figure(), add plots with figure.plot(x,y) and show the figure object with figure.show().

While the curses application is running, the keys are (currently hardcoded) mapped as follows:

  • 'q': quit
  • 'g': toggle legend
  • 't': toggle x-ticks and y-ticks (bottom and left border)
  • 'h', 'j', 'k', 'l': vim-like keybindings for moving the drawing area
  • 'w', 'a', 's', 'd': zoom the drawing area
  • 'x': reset original view (fit all plots in the drawing area)
import numpy
import math
import ncgraph

# Create example plotting data
x = numpy.arange(-3.5, 13.5, .01)
ya = numpy.sin(x)
yb = 1/4*numpy.sin(4*x)
yc = numpy.sin(x) + 1/4*numpy.sin(4*x)
yd = numpy.cos(x) + 1/4*numpy.cos(4*x)

# Direct plotting
ncgraph.plot(x, ya, "sin(x)")

# Multiple plots in a Figure object
fig = ncgraph.Figure()
fig.plot(x, ya, "sin(x)")
fig.plot(x, yb, "(1/4)sin(4x)")
fig.plot(x, yc, "sin(x)+(1/4)sin(4x)")
fig.plot(x, yd, "cos(x)+(1/4)cos(4x)")
fig.show()

# After closing, the Figure object can be shown again
fig.show()

Example Output

ncgraph's People

Contributors

drtobe avatar harrybeadle avatar

Watchers

James Cloos avatar  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.