plotting in the terminal

Related tags

bashplotlib
Overview

bashplotlib

plotting in the terminal

what is it?

bashplotlib is a python package and command line tool for making basic plots in the terminal. It's a quick way to visualize data when you don't have a GUI. It's written in pure python and can quickly be installed anywhere using pip.

installation

install with pip

$ pip install bashplotlib

install from source

$ git clone [email protected]:glamp/bashplotlib.git
$ cd bashplotlib
$ python setup.py install

Either method will install the bashplotlib python package and will also add hist and scatter to your python scripts folder. This folder should be on your path (add it if it's not).

features

  • quick plotting from the command line
  • customize the color, size, title, and shape of plots
  • pipe data into plots with stdin

usage

command line

hist takes input from either stdin or specified using the -f parameter. Input should be a single column of numbers. scatter takes x and y coordinates as input form either a comma delimited file using -f or from 2 different files using -x and -y.

in python

If you want to use bashplotlib from python, just import histogram and scatterplot.

from bashplotlib.scatterplot import plot_scatter

from bashplotlib.histogram import plot_hist

examples

$ scatter --file data/texas.txt --pch .

$ hist --file data/exp.txt

$ scatter -x data/x_test.txt -y data/y_test.txt

todo

  • sideways numbers for x-axis of histograms
  • colors for individual points
  • line charts
  • trendlines
Issues
  • trouble on CentOS 6.7 with  python 2.6

    trouble on CentOS 6.7 with python 2.6

    After installling I am getting following error:

     git clone https://github.com/glamp/bashplotlib.git
     cd bashplotlib
     python setup.py install
    
    
    bashplotlib]$ hist --demo
    Traceback (most recent call last):
      File "/usr/bin/hist", line 9, in <module>
        load_entry_point('bashplotlib==0.6.3', 'console_scripts', 'hist')()
      File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 299, in load_entry_point
        return get_distribution(dist).load_entry_point(group, name)
      File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2229, in load_entry_point
        return ep.load()
      File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1948, in load
        entry = __import__(self.module_name, globals(),globals(), ['__name__'])
      File "/usr/lib/python2.6/site-packages/bashplotlib-0.6.3-py2.6.egg/bashplotlib/histogram.py", line 125
        hist = {i: 0 for i in range(len(bins))}
                       ^
    SyntaxError: invalid syntax
    
    
    opened by arm2arm 3
  • Not supported on Python < 2.7

    Not supported on Python < 2.7

    bashplotlib uses a dictionary comprehension, which was added in 2.7 (and 3.0).

    On 2.6, this produces a syntax error:

    Traceback (most recent call last):
      File "/usr/bin/hist", line 6, in <module>
        from bashplotlib.histogram import plot_hist
      File "/usr/lib/python2.6/site-packages/bashplotlib/histogram.py", line 84
        hist = {i: 0 for i in range(len(bins))}
                       ^
    SyntaxError: invalid syntax
    

    2.6 is still relatively recent (it is, for instance, the "new" Python available on CentOS 5, as python is 2.4), so it'd be nice to include support for it.

    opened by xiongchiamiov 2
  • pip installation issues re 0.5.3 or 0.6.0

    pip installation issues re 0.5.3 or 0.6.0

    As of the submission of this issue, it seems that bashplotlib can't be installed from pypi via pip in a virtualenv; when I do so, pip attempts to install 0.6.0 but fails with the following error:

     IOError: [Errno 2] No such file or directory: 'LICENSE.txt'
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
    
      File "<string>", line 17, in <module>
    
      File "/home/lev/Work/virtualenvs/PYTHON/build/bashplotlib/setup.py", line 11, in <module>
    
        license=open("LICENSE.txt").read(),
    
    IOError: [Errno 2] No such file or directory: 'LICENSE.txt'
    

    Moreover, I noticed that pypi appears to list 0.5.3 as a later release than 0.6.0.

    opened by lebedov 2
  • pip install produces IOError: [Errno 2] No such file or directory: 'LICENSE.txt'

    pip install produces IOError: [Errno 2] No such file or directory: 'LICENSE.txt'

    Here's what I get!

    pip 1.4.1 from /usr/lib/python2.7/dist-packages (python 2.7)

    : minisub ~tmp%; pip install bashplotlib
    Downloading/unpacking bashplotlib
      Downloading bashplotlib-0.5.1.tar.gz
      Running setup.py egg_info for package bashplotlib
        Traceback (most recent call last):
          File "<string>", line 16, in <module>
          File "/tmp/pip_build_danny/bashplotlib/setup.py", line 10, in <module>
            license=open("LICENSE.txt").read(),
        IOError: [Errno 2] No such file or directory: 'LICENSE.txt'
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
    
      File "<string>", line 16, in <module>
    
      File "/tmp/pip_build_danny/bashplotlib/setup.py", line 10, in <module>
    
        license=open("LICENSE.txt").read(),
    
    IOError: [Errno 2] No such file or directory: 'LICENSE.txt'
    
    opened by dannyob 2
  • added functionality to pass in lists to scatter

    added functionality to pass in lists to scatter

    Wanted to be able to pass in two lists as xs, ys

    opened by kennethgoodman 1
  • add standard deviation to histogram summary

    add standard deviation to histogram summary

    Adds data standard deviation to histogram summary output. Demo screenshot

    opened by sboysel 1
  • Switched to using entry_points

    Switched to using entry_points

    Patch for #15

    opened by iiSeymour 1
  • Some refactoring

    Some refactoring

    • Made imports from utils relative to avoid picking up any system wide utils modules
    • Made naming of color and colour standard to colour
    • Added black and default to the list of colours
    • Made default the default colour (can't assume the users background colour will be black)
    • printcolour gets the escape code from get_colour instead of expecting one to be passed in
    • Other small refactoring
    opened by iiSeymour 1
  • parse args with docopt if its installed

    parse args with docopt if its installed

    implemented better docstrings and help using docopt.

    new implementation is backwards compatible, so if docopt is not installed it'll use optparse same as before.

    opened by hernamesbarbara 1
  • Change clone url

    Change clone url

    Attempting git clone [email protected]:glamp/bashplotlib.git throws a permission denied error

    opened by samrobotmesh 1
  • Add x-axis to histogram

    Add x-axis to histogram

    To make the analysis for https://github.com/golang/go/issues/46050#issuecomment-835749005 more meaningful it would be great if the x axis of the histogram could show the bin's values as mentioned in the readme.

    opened by andig 1
  • Error Messages on build?

    Error Messages on build?

    I'm getting the following errors when trying to build using Python3.8

    [email protected]:~/bashplotlib$ python3 setup.py install Traceback (most recent call last): File "setup.py", line 3, in from setuptools import find_packages, setup ModuleNotFoundError: No module named 'setuptools' [email protected]:~/bashplotlib$

    opened by davidjayjackson 0
  • Making histogram

    Making histogram

    I am trying to display a histogram, and it doesn't work, but instead prints -----------... My code is

    with open("cpuhistory.txt", "r") as n:
    
        plot_hist(n)
        n.close()
    

    and cpuhistory.txt is https://pastebin.com/vPMBTxzJ .

    How can I get it working?

    opened by ChopsKingsland 0
  • How do I plot a list of values?

    How do I plot a list of values?

    Say I have a list such as [1,2,3,4..]. How do I make a histogram out of this list?

    opened by rsarky 0
  • Rename `hist` command to something less likely to be a shell builtin

    Rename `hist` command to something less likely to be a shell builtin

    My shell (ksh93) informs me that

    $ type -a hist
    hist is a shell builtin
    hist is /Library/Frameworks/Python.framework/Versions/3.6/bin/hist
    hist is an undefined function
    

    in other words, if I try to run hist I will get the shell builtin first. I can circumvent that by using the env program, but this is not obvious right away.

    opened by kqr 2
  • Adding option --delimiter

    Adding option --delimiter

    opened by Lucas-C 1
  • Add median to hist summary

    Add median to hist summary

    Hi and thanks for this very useful tiny tool!

    In addition to min/mean/max, could you also add the median to the hist summary?

    opened by oschwengers 0
  • Life feed ploting

    Life feed ploting

    Hi

    I wish I could do some "live" ploting. Let's say I'm migrating stuff from server, I'ld like to keep an eye on disk space, I'ld like to do something like

    while true; do sleep 1; df -k / --output=used | tail -n1; done | hist -n
    

    Or maybe

    hist --command 'df -k / --output=used | tail -n1'
    

    Which would draw a simple plot "in place", I mean refreshing it instead of a new one. With a couple of option like rate (plot every X seconds), and horizontal rule (in my example, a value I don't wanna cross)

    I know nowadays it's all about prometheus grafana etc, but a good CLI tool is still priceless for smaller team

    Best regards,

    opened by rgarrigue 0
  • Plot using Python variables

    Plot using Python variables

    I think it'd be nice and not really complicated to add support to plot from two variables in lists/np.array's. This would be useful when e.g. debugging in a command-line in a remote server.

    I can contribute if no one else volunteers to do it and the authors agree on adding this

    opened by marctorsoc 1
  • Include LICENSE in the tarball

    Include LICENSE in the tarball

    Currently the LICENSE is not distributed within the tarball. Can you please include the LICENSE in future distributions?

    opened by CurtLH 0
Owner
Greg Lamp
Greg Lamp
A simple terminal Christmas tree made with Python

Python Christmas Tree A simple CLI Christmas tree made with Python Installation Just clone the repository and run $ python terminal_tree.py More opti

Francisco B. 34 Oct 6, 2021
plotting in the terminal

bashplotlib plotting in the terminal what is it? bashplotlib is a python package and command line tool for making basic plots in the terminal. It's a

Greg Lamp 1.6k Oct 17, 2021
Simple cross-platform colored terminal text in Python

Colorama Makes ANSI escape character sequences (for producing colored terminal text and cursor positioning) work under MS Windows. PyPI for releases |

Jonathan Hartley 2.6k Oct 23, 2021
Python library that measures the width of unicode strings rendered to a terminal

Introduction This library is mainly for CLI programs that carefully produce output for Terminals, or make pretend to be an emulator. Problem Statement

Jeff Quast 250 Oct 15, 2021
Typer, build great CLIs. Easy to code. Based on Python type hints.

Typer, build great CLIs. Easy to code. Based on Python type hints. Documentation: https://typer.tiangolo.com Source Code: https://github.com/tiangolo/

Sebastián Ramírez 6.5k Oct 22, 2021
Color text streams with a polished command line interface

colout(1) -- Color Up Arbitrary Command Output Synopsis colout [-h] [-r RESOURCE] colout [-g] [-c] [-l min,max] [-a] [-t] [-T DIR] [-P DIR] [-d COLORM

nojhan 1.1k Sep 28, 2021
Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer.

Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer. The end goal is to be able to rapidly create rich termin

Will McGugan 5.8k Oct 17, 2021
emoji terminal output for Python

Emoji Emoji for Python. This project was inspired by kyokomi. Example The entire set of Emoji codes as defined by the unicode consortium is supported

Taehoon Kim 1.3k Oct 16, 2021
Python and tab completion, better together.

argcomplete - Bash tab completion for argparse Tab complete all the things! Argcomplete provides easy, extensible command line tab completion of argum

Andrey Kislyuk 991 Oct 22, 2021
A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations

ASCIIMATICS Asciimatics is a package to help people create full-screen text UIs (from interactive forms to ASCII animations) on any platform. It is li

null 2.8k Oct 23, 2021
Cleo allows you to create beautiful and testable command-line interfaces.

Cleo Create beautiful and testable command-line interfaces. Cleo is mostly a higher level wrapper for CliKit, so a lot of the components and utilities

Sébastien Eustace 763 Oct 15, 2021
Cement is an advanced Application Framework for Python, with a primary focus on CLI

Cement Framework Cement is an advanced Application Framework for Python, with a primary focus on Command Line Interfaces (CLI). Its goal is to introdu

Data Folk Labs, LLC 1k Oct 25, 2021