plotting in the terminal

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
Comments
  • 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
  • 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
  • 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
  • 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
  • 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
  • Remove ESC char printing when not needed

    Remove ESC char printing when not needed

    For "default" or unknown (e.g. None) colour do not print ESC characters. This is Useful when storing output into a text file or when running on windows cmd.

    opened by Montvydas 0
  • Fix scatterplot padding

    Fix scatterplot padding

    @glamp I think the padding on scatterplots has gone a bit wonky. This should fix that. Thanks!

    To test, I ran this code:

    from bashplotlib.scatterplot import plot_scatter
    
    plot_scatter(None, [-10,20,30], [10,20,30], 10, 'x', 'default', 'test hello')
    

    Before

    image

    After

    image

    opened by robert 0
  • Fix several ResourceWarnings: unclose file

    Fix several ResourceWarnings: unclose file

    Hello,

    This is a little patch for resource leaks such as:

    $ python setup.py install
    setup.py:14: ResourceWarning: unclosed file <_io.TextIOWrapper name='README.rst' mode='r' encoding='UTF-8'>
      long_description=open("README.rst").read(),
    running install
    ...
    
    $ bash examples/sample.sh
    scatterplot.py:100: ResourceWarning: unclosed file <_io.TextIOWrapper name='examples/data/texas.txt' mode='r' encoding='UTF-8'>
      plot_scatter(opts.f, opts.x, opts.y, opts.size, opts.pch, opts.colour, opts.t)
    with x and y coords
    scatterplot.py:57: ResourceWarning: unclosed file <_io.TextIOWrapper name='examples/data/x_test.txt' mode='r' encoding='UTF-8'>
      xs = [float(str(row).strip()) for row in open(xs)]
    scatterplot.py:58: ResourceWarning: unclosed file <_io.TextIOWrapper name='examples/data/y_test.txt' mode='r' encoding='UTF-8'>
      ys = [float(str(row).strip()) for row in open(ys)]
    
    histogram.py:109: ResourceWarning: unclosed file <_io.TextIOWrapper name='examples/data/exp.txt' mode='r' encoding='UTF-8'>
      f = open(f).readlines()
    

    I also fixed this error:

    Traceback (most recent call last):
      File ".../bin/scatter", line 11, in <module>
        load_entry_point('bashplotlib==0.6.5', 'console_scripts', 'scatter')()
      File "scatterplot.py", line 100, in main
        plot_scatter(opts.f, opts.x, opts.y, opts.size, opts.pch, opts.colour, opts.t)
      File "scatterplot.py", line 74, in plot_scatter
        if cs:
    UnboundLocalError: local variable 'cs' referenced before assignment
    

    Signed-off-by: Mickaël Schoentgen [email protected]

    opened by BoboTiG 0
  • Unambiguous abbreviations of x-labels in histogram

    Unambiguous abbreviations of x-labels in histogram

    The logic behind the choice of string length of x-labels is quite obscure to me, but I believe that the best we can do is to detect the minimum length permitting to distinguish one label from the next one. Implementation is probably not the most efficient one, but I tried to make is as readable as possible, taking into account that we do not expect too many bins (like thousands or millions).

    opened by corrado9999 0
  • Fix formatting in README

    Fix formatting in README

    I added a few newline to fix the formatting around the from bashplotlib.histogram import plot_hist example where the backticks were showing. Thanks! :-)

    opened by bbbbbrie 0
  • 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 3
  • Error Messages on build?

    Error Messages on build?

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

    davidjackson@VirtualBox:~/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' davidjackson@VirtualBox:~/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 2
  • 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
Owner
Greg Lamp
Greg Lamp
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 3k Jan 1, 2023
Rich is a Python library for rich text and beautiful formatting in the terminal.

Rich 中文 readme • lengua española readme • Läs på svenska Rich is a Python library for rich text and beautiful formatting in the terminal. The Rich API

Will McGugan 41.4k Jan 2, 2023
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.6k Jan 2, 2023
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 305 Dec 25, 2022
A thin, practical wrapper around terminal capabilities in Python

Blessings Coding with Blessings looks like this... from blessings import Terminal t = Terminal() print(t.bold('Hi there!')) print(t.bold_red_on_brig

Erik Rose 1.4k Jan 7, 2023
Terminalcmd - a Python library which can help you to make your own terminal program with high-intellegence instruments

Terminalcmd - a Python library which can help you to make your own terminal program with high-intellegence instruments, that will make your code clear and readable.

Dallas 0 Jun 19, 2022
termplotlib is a Python library for all your terminal plotting needs.

termplotlib termplotlib is a Python library for all your terminal plotting needs. It aims to work like matplotlib. Line plots For line plots, termplot

Nico Schlömer 553 Dec 30, 2022
Gamestonk Terminal is an awesome stock and crypto market terminal

Gamestonk Terminal is an awesome stock and crypto market terminal. A FOSS alternative to Bloomberg Terminal.

Gamestonk Terminal 18.6k Jan 3, 2023
Blackjack-Py is a terminal based game of blackjack within your terminal playing against CPU.

About Blackjack-Py is a terminal based game of blackjack within your terminal playing against CPU. Usage Clone the repo and run it with whatever pytho

Eccentrici 1 Dec 28, 2021
Terminal-Video-Player - A program that can display video in the terminal using ascii characters

Terminal-Video-Player - A program that can display video in the terminal using ascii characters

null 15 Nov 10, 2022
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3.4k Dec 29, 2022
Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.

PyDexter Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax. Setup $ pip install PyDexter

D3xter 31 Mar 6, 2021
An intuitive library to add plotting functionality to scikit-learn objects.

Welcome to Scikit-plot Single line functions for detailed visualizations The quickest and easiest way to go from analysis... ...to this. Scikit-plot i

Reiichiro Nakano 2.3k Dec 31, 2022
🎨 Python3 binding for `@AntV/G2Plot` Plotting Library .

PyG2Plot ?? Python3 binding for @AntV/G2Plot which an interactive and responsive charting library. Based on the grammar of graphics, you can easily ma

hustcc 990 Jan 5, 2023
NorthPitch is a python soccer plotting library that sits on top of Matplotlib

NorthPitch is a python soccer plotting library that sits on top of Matplotlib.

Devin Pleuler 30 Feb 22, 2022
matplotlib: plotting with Python

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Check out our home page for more inform

Matplotlib Developers 16.7k Jan 8, 2023
🎨 Python Echarts Plotting Library

pyecharts Python ❤️ ECharts = pyecharts English README ?? 简介 Apache ECharts (incubating) 是一个由百度开源的数据可视化,凭借着良好的交互性,精巧的图表设计,得到了众多开发者的认可。而 Python 是一门富有表达

pyecharts 13.1k Jan 3, 2023
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3.4k Dec 30, 2022
3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)

PyVista Deployment Build Status Metrics Citation License Community 3D plotting and mesh analysis through a streamlined interface for the Visualization

PyVista 1.6k Jan 8, 2023
A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews

hvPlot A high-level plotting API for the PyData ecosystem built on HoloViews. Build Status Coverage Latest dev release Latest release Docs What is it?

HoloViz 697 Jan 6, 2023