๐Ÿ“Š 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
Parallel t-SNE implementation with Python and Torch wrappers.

Multicore t-SNE This is a multicore modification of Barnes-Hut t-SNE by L. Van der Maaten with python and Torch CFFI-based wrappers. This code also wo

Dmitry Ulyanov 1.7k Jan 09, 2023
a python function to plot a geopandas dataframe

Pretty GeoDataFrame A minimum python function (~60 lines) to draw pretty geodataframe. Based on matplotlib, shapely, descartes. Installation just use

haoming 27 Dec 05, 2022
ๅŸบไบŽpython็ˆฌ่™ซ็ˆฌๅ–COVID-19็ˆ†ๅ‘ๅผ€ๅง‹่‡ณไปŠๅ…จ็ƒ็–ซๆƒ…ๆ•ฐๆฎๅนถๅˆฉ็”จEchartsๅฏนๆ•ฐๆฎ่ฟ›่กŒๅˆ†ๆžไธŽๅคšๆ ทๅŒ–ๅฑ•็คบใ€‚

COVID-19-Epidemic-Map ๅŸบไบŽpython็ˆฌ่™ซ็ˆฌๅ–COVID-19็ˆ†ๅ‘ๅผ€ๅง‹่‡ณไปŠๅ…จ็ƒ็–ซๆƒ…ๆ•ฐๆฎๅนถๅˆฉ็”จEchartsๅฏนๆ•ฐๆฎ่ฟ›่กŒๅˆ†ๆžไธŽๅคšๆ ทๅŒ–ๅฑ•็คบใ€‚ ่ง‰ๅพ—้กน็›ฎ่ฟ˜ไธ้”™็š„่ฏๆฌข่ฟŽ็ป™ไธ€ไธชstar! ้กน็›ฎ็š„ๆบ็ ๅฏไปฅๆญฃๅธธ่ฟ่กŒ๏ผŒๅ„ไธชๅบ“็š„็‰ˆๆœฌใ€ๆ•ฐๆฎๅบ“็š„ๅปบ่กจ่ฏญๅฅใ€่ฟ่กŒ่ฟ‡็จ‹ไธญ้‡ๅˆฐ็š„ๅ‘ไปฅๅŠ่งฃๅ†ณๆ–นๅผๅœจ็ฌ”่ฎฐ.mdไธญ้ƒฝ

31 Dec 15, 2022
A Python Library for Self Organizing Map (SOM)

SOMPY A Python Library for Self Organizing Map (SOM) As much as possible, the structure of SOM is similar to somtoolbox in Matlab. It has the followin

Vahid Moosavi 497 Dec 29, 2022
Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python is a GUI-based Python code generator, developed on the Jupyter Notebook environment as an extension.

Visual Python 564 Jan 03, 2023
a plottling library for python, based on D3

Hello August 2013 Hello! Maybe you're looking for a nice Python interface to build interactive, javascript based plots that look as nice as all those

Mike Dewar 1.4k Dec 28, 2022
trade bot connected to binance API/ websocket.,, include dashboard in plotly dash to visualize trades and balances

Crypto trade bot 1. What it is Trading bot connected to Binance API. This project made for fun. So ... Do not use to trade live before you have backte

G 3 Oct 07, 2022
100 data puzzles for pandas, ranging from short and simple to super tricky (60% complete)

100 pandas puzzles Puzzles notebook Solutions notebook Inspired by 100 Numpy exerises, here are 100* short puzzles for testing your knowledge of panda

Alex Riley 1.9k Jan 08, 2023
CLAHE Contrast Limited Adaptive Histogram Equalization

A simple code to process images using contrast limited adaptive histogram equalization. Image processing is becoming a major part of data processig.

Happy N. Monday 4 May 18, 2022
:small_red_triangle: Ternary plotting library for python with matplotlib

python-ternary This is a plotting library for use with matplotlib to make ternary plots plots in the two dimensional simplex projected onto a two dime

Marc 611 Dec 29, 2022
Automatically Visualize any dataset, any size with a single line of code. Created by Ram Seshadri. Collaborators Welcome. Permission Granted upon Request.

AutoViz Automatically Visualize any dataset, any size with a single line of code. AutoViz performs automatic visualization of any dataset with one lin

AutoViz and Auto_ViML 1k Jan 02, 2023
A set of useful perceptually uniform colormaps for plotting scientific data

Colorcet: Collection of perceptually uniform colormaps Build Status Coverage Latest dev release Latest release Docs What is it? Colorcet is a collecti

HoloViz 590 Dec 31, 2022
Analytical Web Apps for Python, R, Julia, and Jupyter. No JavaScript Required.

Dash Dash is the most downloaded, trusted Python framework for building ML & data science web apps. Built on top of Plotly.js, React and Flask, Dash t

Plotly 17.9k Dec 31, 2022
clock_plot provides a simple way to visualize timeseries data, mapping 24 hours onto the 360 degrees of a polar plot

clock_plot clock_plot provides a simple way to visualize timeseries data mapping 24 hours onto the 360 degrees of a polar plot. For usage, please see

12 Aug 24, 2022
Lightweight data validation and adaptation Python library.

Valideer Lightweight data validation and adaptation library for Python. At a Glance: Supports both validation (check if a value is valid) and adaptati

Podio 258 Nov 22, 2022
Generate visualizations of GitHub user and repository statistics using GitHub Actions.

GitHub Stats Visualization Generate visualizations of GitHub user and repository statistics using GitHub Actions. This project is currently a work-in-

Aditya Thakekar 1 Jan 11, 2022
Browse Dash docsets inside emacs

Helm Dash What's it This package uses Dash docsets inside emacs to browse documentation. Here's an article explaining the basic usage of it. It doesn'

504 Dec 15, 2022
1900-2016 Olympic Data Analysis in Python by plotting different graphs

๐Ÿ”ฅ Olympics Data Analysis ๐Ÿ”ฅ In Data Science field, there is a big topic before creating a model for future prediction is Data Analysis. We can find o

Sayan Roy 1 Feb 06, 2022
Official Matplotlib cheat sheets

Official Matplotlib cheat sheets

Matplotlib Developers 6.7k Jan 09, 2023
Small project to recursively calculate and plot each successive order of the Hilbert Curve

hilbert-curve Small project to recursively calculate and plot each successive order of the Hilbert Curve. After watching 3Blue1Brown's video on Hilber

Stefan Mejlgaard 2 Nov 15, 2021