πŸ“Š 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
A TileDB backend for xarray.

TileDB-xarray This library provides a backend engine to xarray using the TileDB Storage Engine. Example usage: import xarray as xr dataset = xr.open_d

TileDB, Inc. 14 Jun 02, 2021
A customized interface for single cell track visualisation based on pcnaDeep and napari.

pcnaDeep-napari A customized interface for single cell track visualisation based on pcnaDeep and napari. πŸ‘€ Under construction You can get test image

ChanLab 2 Nov 07, 2021
The open-source tool for building high-quality datasets and computer vision models

The open-source tool for building high-quality datasets and computer vision models. Website β€’ Docs β€’ Try it Now β€’ Tutorials β€’ Examples β€’ Blog β€’ Commun

Voxel51 2.4k 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
Extensible, parallel implementations of t-SNE

openTSNE openTSNE is a modular Python implementation of t-Distributed Stochasitc Neighbor Embedding (t-SNE) [1], a popular dimensionality-reduction al

Pavlin Poličar 1.1k Jan 03, 2023
Easily convert matplotlib plots from Python into interactive Leaflet web maps.

mplleaflet mplleaflet is a Python library that converts a matplotlib plot into a webpage containing a pannable, zoomable Leaflet map. It can also embe

Jacob Wasserman 502 Dec 28, 2022
An intuitive library to add plotting functionality to scikit-learn objects.

Welcome to Scikit-plot Single line functions for detailed visualizations The quickest and easiest way to go from analysis... ...to this. Scikit-plot i

Reiichiro Nakano 2.3k Dec 31, 2022
A python script editor for napari based on PyQode.

napari-script-editor A python script editor for napari based on PyQode. This napari plugin was generated with Cookiecutter using with @napari's cookie

Robert Haase 9 Sep 20, 2022
Streaming pivot visualization via WebAssembly

Perspective is an interactive visualization component for large, real-time datasets. Originally developed for J.P. Morgan's trading business, Perspect

The Fintech Open Source Foundation (www.finos.org) 5.1k Dec 27, 2022
Python library that makes it easy for data scientists to create charts.

Chartify Chartify is a Python library that makes it easy for data scientists to create charts. Why use Chartify? Consistent input data format: Spend l

Spotify 3.2k Jan 04, 2023
A curated list of awesome Dash (plotly) resources

Awesome Dash A curated list of awesome Dash (plotly) resources Dash is a productive Python framework for building web applications. Written on top of

Luke Singham 1.7k Dec 26, 2022
Sentiment Analysis application created with Python and Dash, hosted at socialsentiment.net

Social Sentiment Dash Application Live-streaming sentiment analysis application created with Python and Dash, hosted at SocialSentiment.net. Dash Tuto

Harrison 456 Dec 25, 2022
Epagneul is a tool to visualize and investigate windows event logs

epagneul Epagneul is a tool to visualize and investigate windows event logs. Dep

jurelou 190 Dec 13, 2022
Collection of scripts for making high quality beautiful math-related posters.

Poster Collection of scripts for making high quality beautiful math-related posters. The poster can have as large printing size as 3x2 square feet wit

Nattawut Phetmak 3 Jun 09, 2022
An interactive UMAP visualization of the MNIST data set.

Code for an interactive UMAP visualization of the MNIST data set. Demo at https://grantcuster.github.io/umap-explorer/. You can read more about the de

grant 70 Dec 27, 2022
Homework 2: Matplotlib and Data Visualization

Homework 2: Matplotlib and Data Visualization Overview These data visualizations were created for my introductory computer science course using Python

Sophia Huang 12 Oct 20, 2022
Here are my graphs for hw_02

Let's Have A Look At Some Graphs! Graph 1: State Mentions in Congressperson's Tweets on 10/01/2017 The graph below uses this data set to demonstrate h

7 Sep 02, 2022
A tool for creating SVG timelines from simple JSON input.

A tool for creating SVG timelines from simple JSON input.

Jason Reisman 432 Dec 30, 2022
A python visualization of the A* path finding algorithm

A python visualization of the A* path finding algorithm. It allows you to pick your start, end location and make obstacles and then view the process of finding the shortest path. You can also choose

Kimeon 4 Aug 02, 2022
Bar Chart of the number of Senators from each party who are up for election in the next three General Elections

Congress-Analysis Bar Chart of the number of Senators from each party who are up for election in the next three General Elections This bar chart shows

11 Oct 26, 2021