πŸ“Š Charts with pure python

Overview

chart

MIT Travis PyPI Downloads

A zero-dependency python package that prints basic charts to a Jupyter output

Charts supported:

  • Bar graphs
  • Scatter plots
  • Histograms
  • πŸ‘ πŸ“Š πŸ‘

Examples

Bar graphs can be drawn quickly with the bar function:

from chart import bar

x = [500, 200, 900, 400]
y = ['marc', 'mummify', 'chart', 'sausagelink']

bar(x, y)
       marc: β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡             
    mummify: β–‡β–‡β–‡β–‡β–‡β–‡β–‡                       
      chart: β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡
sausagelink: β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡β–‡                              

And the bar function can accept columns from a pd.DataFrame:

from chart import bar
import pandas as pd

df = pd.DataFrame({
    'artist': ['Tame Impala', 'Childish Gambino', 'The Knocks'],
    'listens': [8_456_831, 18_185_245, 2_556_448]
})
bar(df.listens, df.artist, width=20, label_width=11, mark='πŸ”Š')
Tame Impala: πŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”Š           
Childish Ga: πŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”ŠπŸ”Š
 The Knocks: πŸ”ŠπŸ”ŠπŸ”Š                                

Histograms are just as easy:

from chart import histogram

x = [1, 2, 4, 3, 3, 1, 7, 9, 9, 1, 3, 2, 1, 2]

histogram(x)
β–‡        
β–‡        
β–‡        
β–‡        
β–‡ β–‡      
β–‡ β–‡      
β–‡ β–‡      
β–‡ β–‡     β–‡
β–‡ β–‡     β–‡
β–‡ β–‡   β–‡ β–‡

And they can accept objects created by scipy:

from chart import histogram
import scipy.stats as stats
import numpy as np

np.random.seed(14)
n = stats.norm(loc=0, scale=10)

histogram(n.rvs(100), bins=14, height=7, mark='πŸ‘')
            πŸ‘              
            πŸ‘   πŸ‘          
            πŸ‘ πŸ‘ πŸ‘          
            πŸ‘ πŸ‘ πŸ‘          
        πŸ‘   πŸ‘ πŸ‘ πŸ‘          
      πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘    
      πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘ πŸ‘   πŸ‘

Scatter plots can be drawn with a simple scatter call:

from chart import scatter

x = range(0, 20)
y = range(0, 20)

scatter(x, y)
                                       β€’
                                   β€’ β€’  
                                 β€’      
                             β€’ β€’        
                         β€’ β€’            
                       β€’                
                  β€’  β€’                  
                β€’                       
            β€’ β€’                         
        β€’ β€’                             
      β€’                                 
  β€’ β€’                                   
β€’                                       

And at this point you gotta know it works with any np.array:

from chart import scatter
import numpy as np

np.random.seed(1)
N = 100
x = np.random.normal(100, 50, size=N)
y = x * -2 + 25 + np.random.normal(0, 25, size=N)

scatter(x, y, width=20, height=9, mark='^')
^^                  
 ^                  
    ^^^             
    ^^^^^^^         
       ^^^^^^       
        ^^^^^^^     
            ^^^^    
             ^^^^^ ^
                ^^ ^

In fact, all chart functions work with pandas, numpy, scipy and regular python objects.

Preprocessors

In order to create the simple outputs generated by bar, histogram, and scatter I had to create a couple of preprocessors, namely: NumberBinarizer and RangeScaler.

I tried to adhere to the scikit-learn API in their construction. Although you won't need them to use chart here they are for your tinkering:

from chart.preprocessing import NumberBinarizer

nb = NumberBinarizer(bins=4)
x = range(10)
nb.fit(x)
nb.transform(x)
[0, 0, 0, 1, 1, 2, 2, 3, 3, 3]
from chart.preprocessing import RangeScaler

rs = RangeScaler(out_range=(0, 10), round=False)
x = range(50, 59)
rs.fit_transform(x)
[0.0, 1.25, 2.5, 3.75, 5.0, 6.25, 7.5, 8.75, 10.0]

Installation

pip install chart

Contribute

For feature requests or bug reports, please use Github Issues

Inspiration

I wanted a super-light-weight library that would allow me to quickly grok data. Matplotlib had too many dependencies, and Altair seemed overkill. Though I really like the idea of termgraph, it didn't really fit well or integrate with my Jupyter workflow. Here's to chart πŸ₯‚ (still can't believe I got it on PyPI)

Owner
Max Humber
Human
Max Humber
Visualization of hidden layer activations of small multilayer perceptrons (MLPs)

MLP Hidden Layer Activation Visualization To gain some intuition about the internal representation of simple multi-layer perceptrons (MLPs) I trained

Andreas KΓΆpf 7 Dec 30, 2022
In-memory Graph Database and Knowledge Graph with Natural Language Interface, compatible with Pandas

CogniPy for Pandas - In-memory Graph Database and Knowledge Graph with Natural Language Interface Whats in the box Reasoning, exploration of RDF/OWL,

Cognitum Octopus 34 Dec 13, 2022
An automatic prover for tautologies in Metamath

completeness An automatic prover for tautologies in Metamath This program implements the constructive proof of the Completeness Theorem for propositio

Scott Fenton 2 Dec 15, 2021
An animation engine for explanatory math videos

Powered By: An animation engine for explanatory math videos Hi there, I'm Zheer πŸ‘‹ I'm a Software Engineer and student!! 🌱 I’m currently learning eve

Zaheer ud Din Faiz 2 Nov 04, 2021
A Bokeh project developed for learning and teaching Bokeh interactive plotting!

Bokeh-Python-Visualization A Bokeh project developed for learning and teaching Bokeh interactive plotting! See my medium blog posts about making bokeh

Will Koehrsen 350 Dec 05, 2022
This is a small repository for me to implement my simply Data Visualisation skills through Python.

Data Visualisations This is a small repository for me to implement my simply Data Visualisation skills through Python. Steam Population Chart from 10/

9 Dec 31, 2021
The interactive graphing library for Python (includes Plotly Express) :sparkles:

plotly.py Latest Release User forum PyPI Downloads License Data Science Workspaces Our recommended IDE for Plotly’s Python graphing library is Dash En

Plotly 12.7k Jan 05, 2023
Simple CLI python app to show a stocks graph performance. Made with Matplotlib and Tiingo.

stock-graph-python Simple CLI python app to show a stocks graph performance. Made with Matplotlib and Tiingo. Tiingo API Key You will need to add your

Toby 3 May 14, 2022
Process dataframe in a easily way.

Popanda Written by Shengxuan Wang at OSU. Used for processing dataframe, especially for machine learning. The name is from "Po" in the movie Kung Fu P

ShawnWang 1 Dec 24, 2021
Easily configurable, chart dashboards from any arbitrary API endpoint. JSON config only

Flask JSONDash Easily configurable, chart dashboards from any arbitrary API endpoint. JSON config only. Ready to go. This project is a flask blueprint

Chris Tabor 3.3k Dec 31, 2022
A set of three functions, useful in geographical calculations of different sorts

GreatCircle A set of three functions, useful in geographical calculations of different sorts. Available for PHP, Python, Javascript and Ruby. Live dem

72 Sep 30, 2022
This package creates clean and beautiful matplotlib plots that work on light and dark backgrounds

This package creates clean and beautiful matplotlib plots that work on light and dark backgrounds. Inspired by the work of Edward Tufte.

Nico SchlΓΆmer 205 Jan 07, 2023
Productivity Tools for Plotly + Pandas

Cufflinks This library binds the power of plotly with the flexibility of pandas for easy plotting. This library is available on https://github.com/san

Jorge Santos 2.7k Dec 30, 2022
A pandas extension that solves all problems of Jalai/Iraninan/Shamsi dates

Jalali Pandas Extentsion A pandas extension that solves all problems of Jalai/Iraninan/Shamsi dates Features Series Extenstion Convert string to Jalal

51 Jan 02, 2023
WhatsApp Chat Analyzer is a WebApp and it can be used by anyone to analyze their chat. πŸ˜„

WhatsApp-Chat-Analyzer You can view the working project here. WhatsApp chat Analyzer is a WebApp where anyone either tech or non-tech person can analy

Prem Chandra Singh 26 Nov 02, 2022
PyFlow is a general purpose visual scripting framework for python

PyFlow is a general purpose visual scripting framework for python. State Base structure of program implemented, such things as packages disco

1.8k Jan 07, 2023
Keir&'s Visualizing Data on Life Expectancy

Keir's Visualizing Data on Life Expectancy Below is information on life expectancy in the United States from 1900-2017. You will also find information

9 Jun 06, 2022
Visualizing weather changes across the world using third party APIs and Python.

WEATHER FORECASTING ACROSS THE WORLD Overview Python scripts were created to visualize the weather for over 500 cities across the world at varying di

G Johnson 0 Jun 12, 2021
Python ts2vg package provides high-performance algorithm implementations to build visibility graphs from time series data.

ts2vg: Time series to visibility graphs The Python ts2vg package provides high-performance algorithm implementations to build visibility graphs from t

Carlos Bergillos 26 Dec 17, 2022
Project coded in Python using Pandas to look at changes in chase% for batters facing a pitcher first time through the order vs. thrid time

Project coded in Python using Pandas to look at changes in chase% for batters facing a pitcher first time through the order vs. thrid time

Jason Kraynak 1 Jan 07, 2022