Skip to content

Commit 7a29f48

Browse files
authored
Adding hex2rgb and rgb2hex function. Adding dvips colors (#14)
* Adding hex2rgb and rgb2hex function. * Adding dvips colors. * Switching off oldest gcc in CI.
1 parent 13720bd commit 7a29f48

10 files changed

Lines changed: 1119 additions & 171 deletions

File tree

.travis.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ env:
77
matrix:
88
fast_finish: true
99
include:
10-
- os: linux
11-
addons:
12-
apt:
13-
sources:
14-
- ubuntu-toolchain-r-test
15-
packages:
16-
- g++-4.9
17-
env: COMPILER=gcc GCC=4.9
1810
- os: linux
1911
addons:
2012
apt:

README.md

Lines changed: 109 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ C++ and Python library specifying colormaps.
2424
<img src="./examples/overview/monocolor.png">
2525
</p>
2626

27+
<p align="center">
28+
<img src="./examples/overview/monocolor_dvips_1.png">
29+
</p>
30+
31+
<p align="center">
32+
<img src="./examples/overview/monocolor_dvips_2.png">
33+
</p>
34+
2735
<p align="center">
2836
<img src="./examples/overview/Qualitative.png">
2937
</p>
@@ -49,9 +57,9 @@ C++ and Python library specifying colormaps.
4957
- [Example](#example)
5058
- [Available colormaps](#available-colormaps)
5159
- [ColorBrewer](#colorbrewer)
52-
- [Matplotlib](#matplotlib)
53-
- [Monochromatic colormaps](#monochromatic-colormaps)
54-
- [Available color-cycles](#available-color-cycles)
60+
- [matplotlib](#matplotlib)
61+
- [monocolor](#monocolor)
62+
- [Available colorcycles](#available-colorcycles)
5563
- [Xterm](#xterm)
5664
- [Eindhoven University of Technology](#eindhoven-university-of-technology)
5765

@@ -122,7 +130,7 @@ int main()
122130
}
123131
```
124132

125-
Note that the colorcycles are not interpolatable. Consequently the functions do have a size option. Note also that the colormaps can also be called directly, e.g.
133+
Note that the colorcycles are not interpolatable. Consequently the functions do have a size option. Note also that the colormaps and colorcycles can also be called directly, e.g.
126134

127135
```cpp
128136
#include <cppcolormap.h>
@@ -237,11 +245,11 @@ N = 256
237245

238246
# specify the colormap as string
239247
cols = cm.colormap("Reds", N)
240-
cols = cm.colorcycle("tue", N)
248+
cols = cm.colorcycle("tue")
241249

242250
# or call the functions directly
243251
cols = cm.Reds(N)
244-
cols = cm.tue(N)
252+
cols = cm.tue()
245253
```
246254

247255
(see lists of [colormaps](#available-colormaps) and [color-cycles](#available-color-cycles) below).
@@ -269,7 +277,7 @@ x, y = np.meshgrid(
269277
np.linspace(0, 1, 100),
270278
np.linspace(0, 1, 100))
271279

272-
d = np.sqrt(x**2 + y**2)
280+
d = np.sqrt(x ** 2.0 + y ** 2.0)
273281

274282
C = cm.Reds(256)
275283
C = np.c_[C, np.ones(C.shape[0])]
@@ -328,7 +336,7 @@ plt.show()
328336
>
329337
> [colorbrewer2.org](http://colorbrewer2.org)
330338
331-
## Matplotlib
339+
## matplotlib
332340

333341
| Name | Inverse colormap |
334342
|----------|------------------|
@@ -345,35 +353,107 @@ plt.show()
345353
>
346354
> [GitHub](https://github.com/BIDS/colormap)
347355
348-
## Monochromatic colormaps
349-
350-
| Name | Inverse colormap |
351-
|----------|------------------|
352-
| White | - |
353-
| Grey | - |
354-
| Black | - |
355-
| Red | - |
356-
| Blue | - |
357-
358-
# Available color-cycles
356+
## monocolor
357+
358+
| Name | Inverse colormap | Source |
359+
|----------------|------------------|--------|
360+
| White | - | - |
361+
| Grey | - | - |
362+
| Black | - | - |
363+
| Red | - | - |
364+
| Blue | - | - |
365+
| tuedarkblue | - | 1 |
366+
| tueblue | - | 1 |
367+
| tuelightblue | - | 1 |
368+
| tuewarmred | - | 1 |
369+
| Apricot | - | 2 |
370+
| Aquamarine | - | 2 |
371+
| Bittersweet | - | 2 |
372+
| Black | - | 2 |
373+
| Blue | - | 2 |
374+
| BlueGreen | - | 2 |
375+
| BlueViolet | - | 2 |
376+
| BrickRed | - | 2 |
377+
| Brown | - | 2 |
378+
| BurntOrange | - | 2 |
379+
| CadetBlue | - | 2 |
380+
| CarnationPink | - | 2 |
381+
| Cerulean | - | 2 |
382+
| CornflowerBlue | - | 2 |
383+
| Cyan | - | 2 |
384+
| Dandelion | - | 2 |
385+
| DarkOrchid | - | 2 |
386+
| Emerald | - | 2 |
387+
| ForestGreen | - | 2 |
388+
| Fuchsia | - | 2 |
389+
| Goldenrod | - | 2 |
390+
| Gray | - | 2 |
391+
| Green | - | 2 |
392+
| GreenYellow | - | 2 |
393+
| JungleGreen | - | 2 |
394+
| Lavender | - | 2 |
395+
| LimeGreen | - | 2 |
396+
| Magenta | - | 2 |
397+
| Mahogany | - | 2 |
398+
| Maroon | - | 2 |
399+
| Melon | - | 2 |
400+
| MidnightBlue | - | 2 |
401+
| Mulberry | - | 2 |
402+
| NavyBlue | - | 2 |
403+
| OliveGreen | - | 2 |
404+
| Orange | - | 2 |
405+
| OrangeRed | - | 2 |
406+
| Orchid | - | 2 |
407+
| Peach | - | 2 |
408+
| Periwinkle | - | 2 |
409+
| PineGreen | - | 2 |
410+
| Plum | - | 2 |
411+
| ProcessBlue | - | 2 |
412+
| Purple | - | 2 |
413+
| RawSienna | - | 2 |
414+
| Red | - | 2 |
415+
| RedOrange | - | 2 |
416+
| RedViolet | - | 2 |
417+
| Rhodamine | - | 2 |
418+
| RoyalBlue | - | 2 |
419+
| RoyalPurple | - | 2 |
420+
| RubineRed | - | 2 |
421+
| Salmon | - | 2 |
422+
| SeaGreen | - | 2 |
423+
| Sepia | - | 2 |
424+
| SkyBlue | - | 2 |
425+
| SpringGreen | - | 2 |
426+
| Tan | - | 2 |
427+
| TealBlue | - | 2 |
428+
| Thistle | - | 2 |
429+
| Turquoise | - | 2 |
430+
| Violet | - | 2 |
431+
| VioletRed | - | 2 |
432+
| White | - | 2 |
433+
| WildStrawberry | - | 2 |
434+
| Yellow | - | 2 |
435+
| YellowGreen | - | 2 |
436+
| YellowOrange | - | 2 |
437+
438+
1. [Eindhoven University of Technology](http://www.tue.nl)
439+
2. [LaTeX xcolor (dvipsnames)](https://en.wikibooks.org/wiki/LaTeX/Colors)
440+
441+
# Available colorcycles
359442

360443
## Xterm
361444

362-
| Name | Inverse colormap |
363-
|----------|------------------|
364-
| xterm | xterm_r |
445+
| Name | Inverse colormap |
446+
|-------|------------------|
447+
| xterm | xterm_r |
365448

366449
> See [this site](https://jonasjacek.github.io/colors/)
367450
368451
## Eindhoven University of Technology
369452

370-
| Name | Inverse colormap |
371-
|--------------|------------------|
372-
| tue | tue_r |
373-
| tuedarkblue | - |
374-
| tueblue | - |
375-
| tuelightblue | - |
376-
| tuewarmred | - |
453+
| Name | Inverse colormap |
454+
|------|------------------|
455+
| tue | tue_r |
456+
377457

378458
> Based on the corporate color scheme of the
379459
> [Eindhoven University of Technology](http://www.tue.nl).

examples/overview/monocolor.png

4.72 KB
Loading
43.1 KB
Loading
44.5 KB
Loading

examples/overview/order_dvips.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import cppcolormap as cm
2+
import numpy as np
3+
4+
names = (
5+
"Apricot",
6+
"Aquamarine",
7+
"Bittersweet",
8+
"Black",
9+
"Blue",
10+
"BlueGreen",
11+
"BlueViolet",
12+
"BrickRed",
13+
"Brown",
14+
"BurntOrange",
15+
"CadetBlue",
16+
"CarnationPink",
17+
"Cerulean",
18+
"CornflowerBlue",
19+
"Cyan",
20+
"Dandelion",
21+
"DarkOrchid",
22+
"Emerald",
23+
"ForestGreen",
24+
"Fuchsia",
25+
"Goldenrod",
26+
"Gray",
27+
"Green",
28+
"GreenYellow",
29+
"JungleGreen",
30+
"Lavender",
31+
"LimeGreen",
32+
"Magenta",
33+
"Mahogany",
34+
"Maroon",
35+
"Melon",
36+
"MidnightBlue",
37+
"Mulberry",
38+
"NavyBlue",
39+
"OliveGreen",
40+
"Orange",
41+
"OrangeRed",
42+
"Orchid",
43+
"Peach",
44+
"Periwinkle",
45+
"PineGreen",
46+
"Plum",
47+
"ProcessBlue",
48+
"Purple",
49+
"RawSienna",
50+
"Red",
51+
"RedOrange",
52+
"RedViolet",
53+
"Rhodamine",
54+
"RoyalBlue",
55+
"RoyalPurple",
56+
"RubineRed",
57+
"Salmon",
58+
"SeaGreen",
59+
"Sepia",
60+
"SkyBlue",
61+
"SpringGreen",
62+
"Tan",
63+
"TealBlue",
64+
"Thistle",
65+
"Turquoise",
66+
"Violet",
67+
"VioletRed",
68+
"WildStrawberry",
69+
"Yellow",
70+
"YellowGreen",
71+
"YellowOrange")
72+
73+
dvips = np.array([list(cm.colormap(name, 1)[0, :]) for name in names])
74+
jet = cm.jet(256)
75+
76+
77+
idx = cm.match(dvips, jet, cm.metric.perceptual)
78+
jdx = np.argsort(idx)
79+
print('\n'.join([names[i] for i in jdx]))

examples/overview/overview.py

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,80 @@
5252
"jet"),
5353
'monocolor' : (
5454
"White",
55+
"Gray",
5556
"Grey",
5657
"Black",
5758
"Red",
5859
"Blue",
60+
"Green",
61+
"Yellow",
62+
"Purple",
63+
"Cyan",
64+
"Orange",
5965
"tuewarmred",
6066
"tuedarkblue",
6167
"tueblue",
62-
"tuelightblue")}
68+
"tuelightblue"),
69+
'monocolor - dvips (1)' : (
70+
"Plum",
71+
"Fuchsia",
72+
"BlueViolet",
73+
"Violet",
74+
"RoyalPurple",
75+
"MidnightBlue",
76+
"NavyBlue",
77+
"RoyalBlue",
78+
"CadetBlue",
79+
"Periwinkle",
80+
"PineGreen",
81+
"Cerulean",
82+
"JungleGreen",
83+
"Emerald",
84+
"TealBlue",
85+
"CornflowerBlue",
86+
"ProcessBlue",
87+
"Aquamarine",
88+
"BlueGreen",
89+
"Turquoise",
90+
"SkyBlue",
91+
"SeaGreen",
92+
"ForestGreen",
93+
"OliveGreen",
94+
"YellowGreen",
95+
"LimeGreen",
96+
"SpringGreen",
97+
"GreenYellow"),
98+
'monocolor - dvips (2)' : (
99+
"Goldenrod",
100+
"Dandelion",
101+
"Apricot",
102+
"YellowOrange",
103+
"Lavender",
104+
"Melon",
105+
"Tan",
106+
"Peach",
107+
"BurntOrange",
108+
"Salmon",
109+
"Thistle",
110+
"CarnationPink",
111+
"Orchid",
112+
"RedOrange",
113+
"VioletRed",
114+
"Rhodamine",
115+
"DarkOrchid",
116+
"Bittersweet",
117+
"WildStrawberry",
118+
"OrangeRed",
119+
"Magenta",
120+
"RubineRed",
121+
"BrickRed",
122+
"Maroon",
123+
"Mulberry",
124+
"Mahogany",
125+
"RedViolet",
126+
"RawSienna",
127+
"Sepia",
128+
"Brown")}
63129

64130
nrows = max(len(cmap_list) for cmap_category, cmap_list in cmaps.items())
65131
gradient = np.linspace(0, 1, 256)
@@ -83,7 +149,7 @@ def plot_color_gradients(cmap_category, cmap_list, nrows):
83149
for ax in axes:
84150
ax.set_axis_off()
85151

86-
plt.savefig(cmap_category + '.png')
152+
plt.savefig(cmap_category.replace(' ', '_').replace('(','').replace(')','').replace('_-_', '_') + '.png')
87153
plt.close()
88154

89155
for cmap_category, cmap_list in cmaps.items():
@@ -116,7 +182,7 @@ def plot_color_gradients(cmap_category, cmap_list, nrows):
116182
for ax in axes:
117183
ax.set_axis_off()
118184

119-
plt.savefig(cmap_category + '.png')
185+
plt.savefig(cmap_category.replace(' ', '_').replace('(','').replace(')','').replace('_-_', '_') + '.png')
120186
plt.close()
121187

122188
plot_color_gradients('Colorcycles', cmaps, nrows)

0 commit comments

Comments
 (0)