Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sample PR] Black Colormap #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions contrib_colormaps/colormaps/black.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
0, 0, 0.1
0.047058823529411764,0.00784313725490196,0.058823529411764705
0.09803921568627451,0.09803921568627451,0.4392156862745098
0.4117647058823529,0.4117647058823529,0.4117647058823529
0.3254901960784314,0.36470588235294116,0.3137254901960784
0.28627450980392155,0.23137254901960785,0.23137254901960785
0.3333333333333333,0.3333333333333333,0.3333333333333333
0.21176470588235294,0.27058823529411763,0.30980392156862746
0.25098039215686274,0.2901960784313726,0.2980392156862745
0.29411764705882354,0.21176470588235294,0.12941176470588237
0.23921568627450981,0.047058823529411764,0.00784313725490196
0.23137254901960785,0.23529411764705882,0.21176470588235294
0.20784313725490197,0.2196078431372549,0.2235294117647059
0.20392156862745098,0.20392156862745098,0.20392156862745098
0.1450980392156863,0.20784313725490197,0.1607843137254902
0.1411764705882353,0.12941176470588237,0.1411764705882353
0.13725490196078433,0.16862745098039217,0.16862745098039217
0.10588235294117647,0.10588235294117647,0.10588235294117647
0.10196078431372549,0.06666666666666667,0.06274509803921569
127 changes: 127 additions & 0 deletions examples/colormaps/black.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Black"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This colormap is constructed from [shades of black](https://en.wikipedia.org/wiki/Shades_of_black). It is meant to be used for qualitative data in an application where a dark colormap is appropriate.\n",
"\n",
"This colormap __is not__:\n",
"* colorblind friendly\n",
"* perceptually uniform"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from contrib_colormaps.plotting import swatch\n",
"import holoviews as hv\n",
"hv.extension('bokeh', 'matplotlib', logo=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"hv.render(swatch('black'), backend='matplotlib')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from bokeh.plotting import show\n",
"show(hv.render(swatch('black'), backend='bokeh'))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import contrib_colormaps as cc\n",
"\n",
"N = len(cc.black)\n",
"data = np.vstack([np.roll(np.arange(N), -i) for i in range(N)])\n",
"dbox = np.vstack([np.hstack([data, np.flip(data, axis=1)]),\n",
" np.hstack([np.flip(data, axis=0), np.flip(data, axis=[0,1])])])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import matplotlib.colors as mcolors\n",
"\n",
"fig, ax = plt.subplots(figsize=(9,9))\n",
"ax.imshow(dbox, cmap=cc.m_black)\n",
"ax.axis('off')\n",
"ax.set_aspect('equal')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from bokeh.plotting import figure, show, output_notebook\n",
"\n",
"output_notebook()\n",
"p = figure()\n",
"p.image([dbox], x=0, y=0, dw=1, dh=1, palette=cc.b_black)\n",
"show(p)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}