GithubHelp home page GithubHelp logo

ascii-boxplot's Introduction

Given a list of datasets, generates lines of output to render a box-and-whisker chart
in ASCII.

Repository includes bin version for commandline usage and lib version for use in another python script.

bin/boxplot.py
Usage: cat data | boxplot.py [options]

Options:
  -h, --help         show this help message and exit
  -w, --width        output width
  -l, --label-width  width of series label
  -b, --box-weight   output scale
  -s, --with-scale   show min and max values


lib/boxplot.py
For example, this input:

render([
        ("test data", [-2.5, -1, 0, 1, 2.5]),
        ("", [-1, 0, 1, 2, 3.5]),
        ("", [0, 1.5, 2, 2.5, 5.5]),
    ])

Produces this output:

          |-2.68333                                                 4.2|
 test data   -------------========0========-------------
  series-2                --------========0=========-------------
  series-3                        ------------=====0====--------------->


The greater-than and less-than signs at the edge indicate that the whisker
has been cut off at this scale.

If the <box_weight> were set to 0.5, <render> would produce this output:

	|-3                                                         3|
test data      ---------------==========O==========---------------

Arguments
    list_of_tuples
	data series to chart
	[('name', []),...]

    width
	Defines the maximum total width of a rendered box-plot, including the series label.
	Defaults to 72.

    label_width
	Defines the width of the space reserved for the series names.  Defaults to 10.

    box_weight
	Defines the output scale in terms of how much of the chart width should be
	used for inter-quartile range boxes (the smallest 1st quartile to the
	largest 3rd quartile).  The default is 1, which means half the width
	is allocated to boxes and the other half allocated to whiskers outside
	the box range (split between the left and right sides).

	Must be a positive number.  As it gets bigger, more whiskers may get
	cut off.  As it gets smaller, there is more room for extremely large
	whiskers, but the box proportions may be obscured.

    with_scale
	If true, the first line returned will show
	the minimum and maximum values displayed on the chart.

	Defaults to True.

Tests
    Install nose:
	pip install nose
    To run tests:
	nosetests tests.py	


Installation
    TODO
    for now, either put bin/boxplot.py on your path or use lib/boxplot.py with your python program


This is a python port of David Golden's perl script: https://github.com/dagolden/text-boxplot
The command-line script is based on Bit.ly's data hacks: https://github.com/bitly/data_hacks


This is free software, licensed under:
The Apache License, Version 2.0, January 2004

ascii-boxplot's People

Contributors

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