πŸ“Š 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
With Holoviews, your data visualizes itself.

HoloViews Stop plotting your data - annotate your data and let it visualize itself. HoloViews is an open-source Python library designed to make data a

HoloViz 2.3k Jan 02, 2023
Collection of data visualizing projects through Tableau, Data Wrapper, and Power BI

Data-Visualization-Projects Collection of data visualizing projects through Tableau, Data Wrapper, and Power BI Indigenous-Brands-Social-Movements Pyt

Jinwoo(Roy) Yoon 1 Feb 05, 2022
Quickly and accurately render even the largest data.

Turn even the largest data into images, accurately Build Status Coverage Latest dev release Latest release Docs Support What is it? Datashader is a da

HoloViz 2.9k Dec 28, 2022
Simple Python interface for Graphviz

Simple Python interface for Graphviz

Sebastian Bank 1.3k Dec 26, 2022
An(other) implementation of JSON Schema for Python

jsonschema jsonschema is an implementation of JSON Schema for Python. from jsonschema import validate # A sample schema, like what we'd get f

Julian Berman 4k Jan 04, 2023
HW 2: Visualizing interesting datasets

HW 2: Visualizing interesting datasets Check out the project instructions here! Mean Earnings per Hour for Males and Females My first graph uses data

7 Oct 27, 2021
A Graph Learning library for Humans

A Graph Learning library for Humans These novel algorithms include but are not limited to: A graph construction and graph searching class can be found

Richard TjΓΆrnhammar 1 Feb 08, 2022
The Timescale NFT Starter Kit is a step-by-step guide to get up and running with collecting, storing, analyzing and visualizing NFT data from OpenSea, using PostgreSQL and TimescaleDB.

Timescale NFT Starter Kit The Timescale NFT Starter Kit is a step-by-step guide to get up and running with collecting, storing, analyzing and visualiz

Timescale 102 Dec 24, 2022
This repository contains a streaming Dataflow pipeline written in Python with Apache Beam, reading data from PubSub.

Sample streaming Dataflow pipeline written in Python This repository contains a streaming Dataflow pipeline written in Python with Apache Beam, readin

Israel Herraiz 9 Mar 18, 2022
Simple addon for snapping active object to mesh ground

Snap to Ground Simple addon for snapping active object to mesh ground How to install: install the Python file as an addon use shortcut "D" in 3D view

Iyad Ahmed 12 Nov 07, 2022
Sci palettes for matplotlib/seaborn

sci palettes for matplotlib/seaborn Installation python3 -m pip install sci-palettes Usage import seaborn as sns import matplotlib.pyplot as plt impor

Qingdong Su 2 Jun 07, 2022
Because trello only have payed options to generate a RunUp chart, this solves that!

Trello Runup Chart Generator The basic concept of the project is that Corello is pay-to-use and want to use Trello To-Do/Doing/Done automation with gi

RΓ΄mulo Schiavon 1 Dec 21, 2021
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
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
By default, networkx has problems with drawing self-loops in graphs.

By default, networkx has problems with drawing self-loops in graphs. It makes it hard to draw a graph with self-loops or to make a nicely looking chord diagram. This repository provides some code to

Vladimir Shitov 5 Jan 06, 2022
Lightweight, extensible data validation library for Python

Cerberus Cerberus is a lightweight and extensible data validation library for Python. v = Validator({'name': {'type': 'string'}}) v.validate({

eve 2.9k Dec 27, 2022
Plot and save the ground truth and predicted results of human 3.6 M and CMU mocap dataset.

Visualization-of-Human3.6M-Dataset Plot and save the ground truth and predicted results of human 3.6 M and CMU mocap dataset. human-motion-prediction

Gaurav Kumar Yadav 5 Nov 18, 2022
A Python toolbox for gaining geometric insights into high-dimensional data

"To deal with hyper-planes in a 14 dimensional space, visualize a 3D space and say 'fourteen' very loudly. Everyone does it." - Geoff Hinton Overview

Contextual Dynamics Laboratory 1.8k Dec 29, 2022
Yata is a fast, simple and easy Data Visulaization tool, running on python dash

Yata is a fast, simple and easy Data Visulaization tool, running on python dash. The main goal of Yata is to provide a easy way for persons with little programming knowledge to visualize their data e

Cybercreek 3 Jun 28, 2021
Generate the report for OCULTest.

Sample report generated in this function Usage example from utils.gen_report import generate_report if __name__ == '__main__': # def generate_rep

Philip Guo 1 Mar 10, 2022