Git Product home page Git Product logo

pyterm-grapher's Introduction

PyTerm-Grapher

Sai Akarsh (12-12-21)

Description

A graphing tool which prints in ASCII on the terminal.
This is a test project with a goal of replicating the matplotlib.pyplot library's basic utilities.

How to use

Here is a sample code snippet,

import numpy as np
import termgrapher as tg

# scatter plot
tg.scatter([1, 2, 3], [5, 2, 4])
tg.show()

# plot
fig = tg.new(50, 100, -5, 5, 0, 25)
x = np.linspace(-5, 5, 10)
tg.plot(x, x**2)
tg.show(fig)

# function plot
tg.new(100, 100, -10, 10, -10, 10)
tg.graph(lambda x, y: y)
tg.graph(lambda x, y: 0.2 * y - np.sin(x))
tg.show()

You can also run the demo.py file to understand the basic functions available.

Features

  • Make a canvas with custom size and range. If you don't create an canvas, then it will use the default canvas. When you create a canvas, it will replace the default with the newly created canvas.
  • Plotting simple 2D graph based on two input arrays x, y.
  • Scatter plot points using two input arrays x, y.
  • Function plot is a new idea. You can plot the function directly rather than precalulating the points and plotting them instead. Function plot does not work as mentioned earlier but used a concept from shaders in Graphics. We calculate the color of each pixel/coordinate using the function output on that coordinate. This is done very efficiently using the magic of numpy.
  • You can print the canvas on the terminal and also save the canvas in a file and load it later on. It uses a simple compression and decompression technique in order to store the canvas in a file to reduce redudancy and save disk space.

pyterm-grapher's People

Contributors

saiakarsh193 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.