tg

A teeny tiny Python tool for graphical function plot.

View on GitHub

Teenygraph

A teeny tiny interative function plotter written in Python3 focused on simplicity and customisation.

Some functions plotted Derivative example

Requirements

The required Python libraries are listed below:

Those can be installed with:

python3 -m pip install graphics.py getch
sudo apt install python3-tk

Initializing

Import tg.py. For the sin() function, math library is also required.

>>> import tg
>>> import math

Select a predefined theme (dark.json or paper.json). For instance:

>>> tg.theme("dark.json")

Call the init function

>>> tg.init(800,10,1)

Empty graph An empty graph will be created with the following properties:
Window size: 800x768
X axis size: 10 (-5 to 5) Grid interval: 1

Define a function that receives a value (x) and returns another (math.sin(x)):

>>> def Sin(x):
...     return math.sin(x)
...
>>>

So, the graph will read:
x: x

y/f(x): math.sin(x)

Plot the defined function:

>>> tg.plot(Sin)

Sinusoid function

More examples are avaliable on examples.py.

Customizing

Color Themes

New JSON color themes can be created acording to the model below:

{
  "Color1": [r,g,b],
  "Color2": [r,g,b],
  "Color3": [r,g,b],
  "Color4": [r,g,b],
  "Color5": [r,g,b]
}