• Stars
    star
    636
  • Rank 70,723 (Top 2 %)
  • Language
    HTML
  • License
    Other
  • Created almost 12 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Colors for data scientists.

iWantHue

Colors for data scientists. Generate and refine palettes of optimally distinct colors.

iWantHue allows you to generate palettes of colors. It is about mastering the properties of a palette by setting a range of Hue, Chroma (unbiased saturation) and Lightness. You can generate palettes of any size or just get the generator for a javascript project. The algorithm optimizes the perceptive distance in the color subspace, ensuring an optimal readability.

How it works

  1. K-means or force vector repulsion algorithms ensure an even distribution of colors
  2. The CIE Lab color space is used for computation, since it fits human perception
  3. The Hue/Chroma/Lightness color space is used to set constraints, since it is user-friendly

Examples and a tutorial

Idea

The idea behind iWantHue is to distribute colors evenly, in a perceptively coherent space, constrained by user-friendly settings, to generate high quality custom palettes.

Explanations and an experiment on color theory

How to use it in your own code

You can install iwanthue for node.js and the browser using npm:

npm install iwanthue

Usage

var iwanthue = require('iwanthue');

// Generate a simple palette with 5 colors
var palette = iwanthue(5);

// With some options
var palette = iwanthue(5, {
  clustering: 'force-vector',
  seed: 'cool-palette',
  quality: 100
});

Arguments

  • count number: number of colors in the generated palette.
  • settings ?object: Settings:
    • attempts ?number [1]: Number of times should the function try to generate a palette in order to only keep the one maximizing the minimum distance between two of the palette colors. Will only make a single attempt by default.
    • colorSpace ?string|object|array [default]: Color space preset. Check this file for the full list of preset names, or go to the website to try them. Alternatively you can pass the colorSpace either as a [hmin, hmax, cmin, cmax, lmin, lmax] array or a {hmin, hmax, cmin, cmax, lmin, lmax} object where keys can be omitted.
    • colorFilter ?function: Function used to filter suitable colors. Takes a [r, g, b] color and the same [l, a, b] color as arguments.
    • clustering ?string [k-means]: Clustering method to use. Can either be k-means or force-vector.
    • quality ?number [50]: Quality of the clustering: iterations factor for force-vector, colorspace sampling for k-means.
    • ultraPrecision ?boolean [false]: Ultra precision for k-means colorspace sampling?
    • distance ?string [euclidean]: Distance function to use. Can be euclidean, cmc, compromise (colorblind), protanope, deuteranope or tritanope.
    • seed ?string|number: Random number generator seed. Useful to produce the same palette every time based on some data attribute.

Palette

A helper class representing a categorical color palette over a set of given values.

// To build your palette from a unique list of values
var Palette = require('iwanthue/palette');

var palette = Palette.generateFromValues(
  'cities',
  ['one', 'two', 'three'],
  {defaultColor: '#000'}
);

palette.get('one');
>>> '#19d3a2'

palette.get('unknown');
>>> '#000'

// From entries
var palette = Palette.fromEntries(
  'cities',
  [['one', 'red'], ['two', 'blue']],
  '#000'
);

// From mapping
var palette = Palette.fromMapping(
  'cities',
  {one: 'red', two: 'blue'},
  'red'
);

Palette.generateFromValues arguments

  • name string: palette or category name used as seed for iwanthue.
  • values iter: unique values for the represented category.
  • settings ?object:
    • defaultColor ?string [#ccc]: default color to return in case desired value is not known.
    • ... any setting that can be passed to iwanthue.

Palette.fromEntries arguments

  • name string: palette or category name used as seed for iwanthue.
  • entries iter: key, value entries mapping values to colors.
  • defaultColor ?string [#ccc]: default color to return in case desired value is not known.

Palette.fromMapping arguments

  • name string: palette or category name used as seed for iwanthue.
  • mapping object|Map: mapping from values to colors.
  • defaultColor ?string [#ccc]: default color to return in case desired value is not known.

Palette.fromJSON arguments

  • data object: serialized palette data ({name, defaultColor, entries}).

Palette members

  • name string: name of the palette.
  • size number: number of colors.
  • defaultColor string: default color.
  • map Map: map from values to colors.

Palette methods

  • get: return the color for the given value or the default color if value is unkown.
  • has: return whether the value is known to the palette.
  • forEach: callback iteration over (color, value).
  • colors: return the palette's colors as an array.
  • toJSON: return the palette in a serialized format fit for JSON.

Precomputed palettes

If you don't want to load iwanthue's whole code into your client app or if you just want to prototype things quickly, the npm module also packs some precomputed palettes that you can import.

All of the presets export palettes ranging from 2 to 15 colors.

Here is how to load them:

// Default palettes
var palettes = require('iwanthue/precomputed');

// Need a palette for 6 colors:
var sixColorsPalette = palettes[6];

// K-means palettes
var palettes = require('iwanthue/precomputed/k-means');

// Force vector palettes
var palettes = require('iwanthue/precomputed/force-vector');

// Colorblind alternatives
var palettes = require('iwanthue/precomputed/k-means-colorblind');
var palettes = require('iwanthue/precomputed/force-vector-colorblind');

Here is the full list of precomputed palettes:

iwanthue/precomputed/force-vector
iwanthue/precomputed/index
iwanthue/precomputed/k-means
iwanthue/precomputed/ultra-k-means
iwanthue/precomputed/force-vector-colorblind
iwanthue/precomputed/k-means-colorblind
iwanthue/precomputed/k-means-all
iwanthue/precomputed/force-vector-all
iwanthue/precomputed/k-means-fancy-light
iwanthue/precomputed/force-vector-fancy-light
iwanthue/precomputed/k-means-fancy-dark
iwanthue/precomputed/force-vector-fancy-dark
iwanthue/precomputed/k-means-shades
iwanthue/precomputed/force-vector-shades
iwanthue/precomputed/k-means-tarnish
iwanthue/precomputed/force-vector-tarnish
iwanthue/precomputed/k-means-pastel
iwanthue/precomputed/force-vector-pastel
iwanthue/precomputed/k-means-pimp
iwanthue/precomputed/force-vector-pimp
iwanthue/precomputed/k-means-intense
iwanthue/precomputed/force-vector-intense
iwanthue/precomputed/k-means-fluo
iwanthue/precomputed/force-vector-fluo
iwanthue/precomputed/k-means-red-roses
iwanthue/precomputed/force-vector-red-roses
iwanthue/precomputed/k-means-ochre-sand
iwanthue/precomputed/force-vector-ochre-sand
iwanthue/precomputed/k-means-yellow-lime
iwanthue/precomputed/force-vector-yellow-lime
iwanthue/precomputed/k-means-green-mint
iwanthue/precomputed/force-vector-green-mint
iwanthue/precomputed/k-means-ice-cube
iwanthue/precomputed/force-vector-ice-cube
iwanthue/precomputed/k-means-blue-ocean
iwanthue/precomputed/force-vector-blue-ocean
iwanthue/precomputed/k-means-indigo-night
iwanthue/precomputed/force-vector-indigo-night
iwanthue/precomputed/k-means-purple-wine
iwanthue/precomputed/force-vector-purple-wine

More info

More Repositories

1

artoo

artoo.js - the client-side scraping companion.
JavaScript
1,100
star
2

hyphe

Websites crawler with built-in exploration and control web interface
JavaScript
328
star
3

minet

A webmining CLI tool & library for python.
Python
285
star
4

ipysigma

A Jupyter widget using sigma.js to render interactive networks.
Jupyter Notebook
193
star
5

sandcrawler

sandcrawler.js - the server-side scraping companion.
JavaScript
107
star
6

gazouilloire

Twitter stream + search API grabber
Python
104
star
7

fonio

a collaborative scholarly text editor allowing to build static websites
JavaScript
67
star
8

ural

A helper library full of URL-related heuristics.
Python
61
star
9

ANTA

Actor Network Text Analyser
PHP
56
star
10

zup

a simple interface from extracting texts from (almost) any url
JavaScript
52
star
11

manylines

Explore networks and publish narratives.
HTML
52
star
12

xan

The CSV magician
Rust
42
star
13

hyphe-browser

Browser version of Hyphe (WIP)
JavaScript
29
star
14

tesselle

an image annotation and publication tool
TypeScript
27
star
15

csv-rinse-repeat

CSV grooming, the JS way
JavaScript
21
star
16

scholarScape

Python
21
star
17

minivan

Web interface for network analysis.
JavaScript
20
star
18

sandcrawler-dashboard

A handy terminal dashboard plugin for sandcrawler.
JavaScript
20
star
19

table2net

JavaScript
20
star
20

graph-recipes

Online experimental network tinkering
JavaScript
18
star
21

ricardo_data

The RICardo dataset compiles trade statistics sources of international trade bilateral flows of the 19th century.
Python
16
star
22

drive-in

publish a simple website from a public google drive folder
JavaScript
16
star
23

sciencescape

sciencescape
JavaScript
16
star
24

toflit18

TOFLIT18 datascape's sources.
JavaScript
14
star
25

google-bookmarklets

extract list of results from a google page as csv with bookmarklets
JavaScript
14
star
26

aime-core

Core engine of the AIME project serving its harmonized database.
JavaScript
14
star
27

ricardo

RICardo Project, Historical Trade Database
JavaScript
13
star
28

bibliotools3.0

modification of bibliotools 2.2 from Sébastian Grauwin
Python
12
star
29

website

The lab's static website and its admin.
JavaScript
12
star
30

casanova

Specialized & performant CSV readers, writers and enrichers for python.
Python
11
star
31

Facettage

Facet management for backendless datascapes
JavaScript
11
star
32

heatgraph

you don't want to know
JavaScript
11
star
33

reference_manager

Python
10
star
34

twitwi

Collection of Twitter-related helper functions for python.
Python
10
star
35

hyphe-traph

A Trie/Graph hybrid memory structure used by the Hyphe crawler to index pages & webentities.
Python
10
star
36

pelote

A collection of network-related python utilities.
Python
9
star
37

hyphe2solr

XSLT
8
star
38

benchmarkForceAtlas2

JavaScript
8
star
39

bothan

A node.js phantom interface for scraping purposes.
JavaScript
8
star
40

GeoPolHist

TypeScript
7
star
41

quenouille

A library of multithreaded iterator workflows for python.
Python
6
star
42

gulp-artoo

A gulp plugin to create artoo.js bookmarklets.
JavaScript
6
star
43

drive-out

Export of google drive private folders for node.js
JavaScript
5
star
44

catwalk

Nano tweet curation tool for humanities
JavaScript
5
star
45

LDA_testing

Collection of scripts testing various implementation of and wrapping around LDA
Python
5
star
46

bhht-datascape

The BHHT project's datascape.
JavaScript
5
star
47

ANTA2

Actor Network Text Analyser v2
Python
5
star
48

reanalyse

django platform to explore TEI verbatims, documents & speakers within structured qualitative studies
JavaScript
5
star
49

doxer

experimental ngram extractor (using django + solr)
XSLT
4
star
50

grunt-artoo

A grunt task to create artoo bookmarklets.
JavaScript
4
star
51

ouatterrir

WIP
JavaScript
4
star
52

scrapers

Miscellaneous scrapers.
Python
4
star
53

toflit18_data

Datapackage for TOFLIT18 research project
Stata
4
star
54

gitlaw

Python
4
star
55

halexp

medialab's expert search engine poc
Python
4
star
56

resin-annuaire

Site de l'annuaire des expertises du Réseau d'Ingenieur USPC/SciencesPo
JavaScript
3
star
57

fabrique-fragmentation

A prototype for La Fabrique de la Loi : réseaux d'alignement et fragmentation des groupes politiques
JavaScript
3
star
58

quinoa-server

Node application providing diverse services for quinoa apps
JavaScript
3
star
59

communautes-libres-graph

TypeScript
3
star
60

digital-training-topics

HTML
3
star
61

mango_cognitive

Set of cognitive games to be added to a limesurvey platform.
JavaScript
3
star
62

frontcast

JavaScript
3
star
63

medialab-network-dataset

Various GEXF networks from our studies
3
star
64

portic-storymaps-2021

source code for the PORTIC datasprint 2021 publication
JavaScript
3
star
65

bottom-up-color-space-experiment

Online experiment to build color spaces from empirical color distances in various contexts
JavaScript
3
star
66

cours-facebook

3
star
67

mango_core

Mango "plugin" for limesurvey. Used to add a surveys router to chain survey one after the other.
PHP
2
star
68

navicrawler

Archive repository for WebAtlas' NaviCrawler project
JavaScript
2
star
69

ipinion-rank

Python
2
star
70

quinoa-vis-modules

[WIP] Set of api-consistent visualization react components for quinoa apps
JavaScript
2
star
71

tools-old

HTML
2
star
72

unfccc-scrap-snippet

A code snippet used to scrape UNFCCC data during EMAPS project
2
star
73

habitele

JavaScript
2
star
74

otree-iat

Implicit Association Test for oTree.
JavaScript
2
star
75

controversy-mapping

Controversy Mapping Archive
CSS
2
star
76

double-dating-data

mini website for the exhibition
HTML
2
star
77

bulgur

JavaScript
2
star
78

amendement

Parsing des amendements
JavaScript
2
star
79

nyt-api

fetch nyt articles, store them into db, display authors
JavaScript
2
star
80

spatialization-quality

JavaScript
2
star
81

graines

Classification of Twitter users using multimodal embeddings
HTML
2
star
82

portic-datasprint-2021

Ce répertoire contient un ensemble de ressources utiles, et les productions des participants du datasprint PORTIC 2021 qui s'est tenu les 6, 7, 8 et 9 avril 2021.
Jupyter Notebook
2
star
83

rebus

A writing tool materializing distant echoes from twitter data
JavaScript
1
star
84

Gazou_twint_sns_comp

Python
1
star
85

well-being-metrics

A mini website for SoWell project
CSS
1
star
86

medialab.sciences-po.fr

The médialab website source code : a Wordpress theme
PHP
1
star
87

FlaskTools

Python
1
star
88

tweet-bubbles

Small python script generating a tweet bubbles dataviz.
Python
1
star
89

fabrique-typo-amendements

Jupyter Notebook
1
star
90

poltergeist

theme for ghost (node.js blogging platform)
CSS
1
star
91

artoratoire

JavaScript
1
star
92

loubar

Just some experiments in visualizing the inner workings of a graph community detection algorithms.
TypeScript
1
star
93

webclim_misinformation_related_interventions

TeX
1
star
94

carnet-algopresse

An ongoing experiment about setting a workflow for collectively refining visualizations and their textual apparatus
JavaScript
1
star
95

aime-tweets

Collect Bruno Latour's tweet for display on ModesOfExistence.org
Python
1
star
96

cnap-fnac

HTML
1
star
97

hyphe-topic-datascape

A prototype datascape to explore the content of a Hyphe corpus where topics have been added to web pages
CSS
1
star
98

benchmarkNetworkCut

1
star
99

MappingFrenchRussia

JavaScript
1
star
100

personal-air-timeline

a SaveOurAir experiment
JavaScript
1
star