πŸ“Š 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
Scientific Visualization: Python + Matplotlib

An open access book on scientific visualization using python and matplotlib

Nicolas P. Rougier 8.6k Dec 31, 2022
DataVisualization - The evolution of my arduino and python journey. New level of competence achieved

DataVisualization - The evolution of my arduino and python journey. New level of competence achieved

1 Jan 03, 2022
ipyvizzu - Jupyter notebook integration of Vizzu

ipyvizzu - Jupyter notebook integration of Vizzu. Tutorial Β· Examples Β· Repository About The Project ipyvizzu is the Jupyter Notebook integration of V

Vizzu 729 Jan 08, 2023
Flame Graphs visualize profiled code

Flame Graphs visualize profiled code

Brendan Gregg 14.1k Jan 03, 2023
Tools for exploratory data analysis in Python

Dora Exploratory data analysis toolkit for Python. Contents Summary Setup Usage Reading Data & Configuration Cleaning Feature Selection & Extraction V

Nathan Epstein 599 Dec 25, 2022
A napari plugin for visualising and interacting with electron cryotomograms.

napari-tomoslice A napari plugin for visualising and interacting with electron cryotomograms. Installation You can install napari-tomoslice via pip: p

3 Jan 03, 2023
A small timeseries transformation API built on Flask and Pandas

#Mcflyin ###A timeseries transformation API built on Pandas and Flask This is a small demo of an API to do timeseries transformations built on Flask a

Rob Story 84 Mar 25, 2022
GD-UltraHack - A Mod Menu for Geometry Dash. Specifically a MegahackV5 clone in Python. Only for Windows

GD UltraHack: The Mod Menu that Nobody asked for. This is a mod menu for the gam

zeo 1 Jan 05, 2022
649 PokΓ©mon palettes as CSVs, with a Python lib to turn names/IDs into palettes, or MatPlotLib compatible ListedColormaps.

PokePalette 649 PokΓ©mon, broken down into CSVs of their RGB colour palettes. Complete with a Python library to convert names or PokΓ©dex IDs into eithe

11 Dec 05, 2022
Visualize tensors in a plain Python REPL using Sparklines

Visualize tensors in a plain Python REPL using Sparklines

Shawn Presser 43 Sep 03, 2022
Tandem Mass Spectrum Prediction with Graph Transformers

MassFormer This is the original implementation of MassFormer, a graph transformer for small molecule MS/MS prediction. Check out the preprint on arxiv

RΓΆst Lab 13 Oct 27, 2022
Automatically visualize your pandas dataframe via a single print! πŸ“Š πŸ’‘

A Python API for Intelligent Visual Discovery Lux is a Python library that facilitate fast and easy data exploration by automating the visualization a

Lux 4.3k Dec 28, 2022
Visualizations of some specific solutions of different differential equations.

Diff_sims Visualizations of some specific solutions of different differential equations. Heat Equation in 1 Dimension (A very beautiful and elegant ex

2 Jan 13, 2022
visualize_ML is a python package made to visualize some of the steps involved while dealing with a Machine Learning problem

visualize_ML visualize_ML is a python package made to visualize some of the steps involved while dealing with a Machine Learning problem. It is build

Ayush Singh 164 Dec 12, 2022
OpenStats is a library built on top of streamlit that extracts data from the Github API and shows the main KPIs

Open Stats Discover and share the KPIs of your OpenSource project. OpenStats is a library built on top of streamlit that extracts data from the Github

Pere Miquel Brull 4 Apr 03, 2022
Ana's Portfolio

Ana's Portfolio ✌️ Welcome to my Portfolio! You will find here different Projects I have worked on (from scratch) πŸ’ͺ Projects πŸ’» 1️⃣ Hangman game (Mad

Ana Katherine Cortes Sobrino 9 Mar 15, 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
Data visualization electromagnetic spectrum

Datenvisualisierung-Elektromagnetischen-Spektrum Anhand des Moduls matplotlib sollen die Daten des elektromagnetischen Spektrums dargestellt werden. D

Pulsar 1 Sep 01, 2022
A research of IT labor market based especially on hh.ru. Salaries, rate of technologies and etc.

hh_ru_research ΠŸΡ€ΠΎΠ΅ΠΊΡ‚ Ρ€Π΅Π°Π»ΠΈΠ·ΠΎΠ²Π°Π½ Π² ΡƒΡ‡Π΅Π±Π½Ρ‹Ρ… цСлях Π°Π½Π°Π»ΠΈΠ·Π° Ρ€Ρ‹Π½ΠΊΠ° Ρ‚Ρ€ΡƒΠ΄Π°, Π² особСнности ΠΏΠΎ hh.ru Input data Π’ качСствС Π²Ρ…ΠΎΠ΄Π½Ρ‹Ρ… Π΄Π°Π½Π½Ρ‹Ρ… ΠΈΡΠΏΠΎΠ»ΡŒΠ·ΡƒΡŽΡ‚ΡΡ сСриали

3 Sep 07, 2022
Blender addon that creates a temporary window of any type from the 3D View.

CreateTempWindow2.8 Blender addon that creates a temporary window of any type from the 3D View. Features Can the following window types: 3D View Graph

3 Nov 27, 2022