mkaz / termgraph

a python command-line tool which draws basic graphs in the terminal
MIT License
3.15k stars 164 forks source link

Documentation to use termgraph as python module within python script #96

Open davytan07 opened 2 years ago

davytan07 commented 2 years ago

Hi, is there any documentation for how to use termgraph within a .py script instead of on the terminal? Was searching for any form of documentation online, and I found the following code which works, thus I was wondering how I could do the same on a .py script for horizontal graphs:

from termgraph import termgraph as tg

labels = ['2007', '2008', '2009', '2010', '2011', '2012', '2014'] data = [[183.32, 190.52], [231.23, 5.0], [16.43, 53.1], [50.21, 7.0], [508.97, 10.45], [212.05, 20.2], [30.0, 20.0]] normal_data = [[48.059508408796894, 50.0], [60.971862871927556, 0.0], [3.080530401034929, 12.963561880120743], [12.184670116429496, 0.5390254420008624], [135.82632600258734, 1.4688443294523499], [55.802608883139285, 4.096593359206555], [6.737818025010781, 4.042690815006468]] len_categories = 2 args = {'filename': 'data/ex4.dat', 'title': None, 'width': 50, 'format': '{:<5.2f}', 'suffix': '', 'no_labels': True, 'color': None, 'vertical': False, 'stacked': True, 'different_scale': False, 'calendar': False, 'start_dt': None, 'custom_tick': '', 'delim': '', 'verbose': False, 'version': False} colors = [91, 94] tg.stacked_graph(labels, data, normal_data, len_categories, args, colors)