https://github.com/plotly/colorlover
Color scales in Python for humans
https://github.com/plotly/colorlover
Last synced: 15 days ago
JSON representation
Color scales in Python for humans
- Host: GitHub
- URL: https://github.com/plotly/colorlover
- Owner: plotly
- License: other
- Created: 2015-01-30T03:37:49.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-01-27T14:38:01.000Z (11 months ago)
- Last Synced: 2025-06-19T21:17:44.026Z (6 months ago)
- Language: Python
- Homepage:
- Size: 52.7 KB
- Stars: 161
- Watchers: 7
- Forks: 18
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# colorlover
Color scales for humans
IPython notebook: https://plot.ly/ipython-notebooks/color-scales/
```
import colorlover as cl
from IPython.display import HTML
HTML(cl.to_html( cl.flipper()['seq']['3'] ))
```

## Install
```
sudo pip install colorlover
```
## IPython notebook (demo)
https://plot.ly/ipython-notebooks/color-scales/
## Docs
### cl.scales
All of the color scales in colorlover
```
>>> import colorlover as cl
>>> cl.scales['3']['div']['RdYlBu']
['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']
```
### cl.to_numeric( scale )
Converts scale of RGB or HSL strings to list of tuples with RGB integer values
```
>>> cl.to_numeric( cl.scales['3']['div']['RdYlBu'] )
[(252.0, 141.0, 89.0), (255.0, 255.0, 191.0), (145.0, 191.0, 219.0)]
```
### cl.to_hsl( scale )
Converts a string RGB or numeric RGB colorscale to HSL
```
>>> cl.to_hsl( cl.scales['3']['div']['RdYlBu'] )
['hsl(19.0, 96.0%, 67.0%)', 'hsl(60.0, 100.0%, 87.0%)', 'hsl(203.0, 51.0%, 71.0%)']
```
### cl.to_rgb( scale )
Convert an HSL or numeric RGB color scale to string RGB color scale
```
>>> cl.to_rgb( cl.scales['3']['div']['RdYlBu'] )
['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']
```
### cl.to_html( scale )
Traverse color scale dictionary and return available color scales as HTML string
```
>>> cl.to_html( cl.scales['3']['div']['RdYlBu'] )
'
'
```
### cl.flipper( scale=None )
Return the inverse of the color scale dictionary cl.scale
```
>>> cl.flipper()['div']['3']['RdYlBu']
['rgb(252,141,89)', 'rgb(255,255,191)', 'rgb(145,191,219)']
```
### cl.interp( scale, r )
def interp(scl, r):
Interpolate a color scale "scale" to a new one with length "r"
```
# fun usage in IPython notebook
from IPython.display import HTML
HTML( to_html( to_hsl( interp( cl.scales['11']['qual']['Paired'], 5000 ) ) ) )
```
## All colors in cl.scales
```
# (in IPython notebook)
from IPython.display import HTML
HTML(cl.to_html( cl.scales ))
```