Skip to content

Commit

Permalink
Adding hex2rgb and rgb2hex function. Adding dvips colors (#14)
Browse files Browse the repository at this point in the history
* Adding hex2rgb and rgb2hex function. 
* Adding dvips colors.
* Switching off oldest gcc in CI.
  • Loading branch information
tdegeus authored Dec 11, 2019
1 parent 13720bd commit 7a29f48
Show file tree
Hide file tree
Showing 10 changed files with 1,119 additions and 171 deletions.
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ env:
matrix:
fast_finish: true
include:
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
env: COMPILER=gcc GCC=4.9
- os: linux
addons:
apt:
Expand Down
138 changes: 109 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ C++ and Python library specifying colormaps.
<img src="./examples/overview/monocolor.png">
</p>

<p align="center">
<img src="./examples/overview/monocolor_dvips_1.png">
</p>

<p align="center">
<img src="./examples/overview/monocolor_dvips_2.png">
</p>

<p align="center">
<img src="./examples/overview/Qualitative.png">
</p>
Expand All @@ -49,9 +57,9 @@ C++ and Python library specifying colormaps.
- [Example](#example)
- [Available colormaps](#available-colormaps)
- [ColorBrewer](#colorbrewer)
- [Matplotlib](#matplotlib)
- [Monochromatic colormaps](#monochromatic-colormaps)
- [Available color-cycles](#available-color-cycles)
- [matplotlib](#matplotlib)
- [monocolor](#monocolor)
- [Available colorcycles](#available-colorcycles)
- [Xterm](#xterm)
- [Eindhoven University of Technology](#eindhoven-university-of-technology)

Expand Down Expand Up @@ -122,7 +130,7 @@ int main()
}
```

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.
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.

```cpp
#include <cppcolormap.h>
Expand Down Expand Up @@ -237,11 +245,11 @@ N = 256

# specify the colormap as string
cols = cm.colormap("Reds", N)
cols = cm.colorcycle("tue", N)
cols = cm.colorcycle("tue")

# or call the functions directly
cols = cm.Reds(N)
cols = cm.tue(N)
cols = cm.tue()
```

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

d = np.sqrt(x**2 + y**2)
d = np.sqrt(x ** 2.0 + y ** 2.0)

C = cm.Reds(256)
C = np.c_[C, np.ones(C.shape[0])]
Expand Down Expand Up @@ -328,7 +336,7 @@ plt.show()
>
> [colorbrewer2.org](http://colorbrewer2.org)
## Matplotlib
## matplotlib

| Name | Inverse colormap |
|----------|------------------|
Expand All @@ -345,35 +353,107 @@ plt.show()
>
> [GitHub](https://github.com/BIDS/colormap)
## Monochromatic colormaps

| Name | Inverse colormap |
|----------|------------------|
| White | - |
| Grey | - |
| Black | - |
| Red | - |
| Blue | - |

# Available color-cycles
## monocolor

| Name | Inverse colormap | Source |
|----------------|------------------|--------|
| White | - | - |
| Grey | - | - |
| Black | - | - |
| Red | - | - |
| Blue | - | - |
| tuedarkblue | - | 1 |
| tueblue | - | 1 |
| tuelightblue | - | 1 |
| tuewarmred | - | 1 |
| Apricot | - | 2 |
| Aquamarine | - | 2 |
| Bittersweet | - | 2 |
| Black | - | 2 |
| Blue | - | 2 |
| BlueGreen | - | 2 |
| BlueViolet | - | 2 |
| BrickRed | - | 2 |
| Brown | - | 2 |
| BurntOrange | - | 2 |
| CadetBlue | - | 2 |
| CarnationPink | - | 2 |
| Cerulean | - | 2 |
| CornflowerBlue | - | 2 |
| Cyan | - | 2 |
| Dandelion | - | 2 |
| DarkOrchid | - | 2 |
| Emerald | - | 2 |
| ForestGreen | - | 2 |
| Fuchsia | - | 2 |
| Goldenrod | - | 2 |
| Gray | - | 2 |
| Green | - | 2 |
| GreenYellow | - | 2 |
| JungleGreen | - | 2 |
| Lavender | - | 2 |
| LimeGreen | - | 2 |
| Magenta | - | 2 |
| Mahogany | - | 2 |
| Maroon | - | 2 |
| Melon | - | 2 |
| MidnightBlue | - | 2 |
| Mulberry | - | 2 |
| NavyBlue | - | 2 |
| OliveGreen | - | 2 |
| Orange | - | 2 |
| OrangeRed | - | 2 |
| Orchid | - | 2 |
| Peach | - | 2 |
| Periwinkle | - | 2 |
| PineGreen | - | 2 |
| Plum | - | 2 |
| ProcessBlue | - | 2 |
| Purple | - | 2 |
| RawSienna | - | 2 |
| Red | - | 2 |
| RedOrange | - | 2 |
| RedViolet | - | 2 |
| Rhodamine | - | 2 |
| RoyalBlue | - | 2 |
| RoyalPurple | - | 2 |
| RubineRed | - | 2 |
| Salmon | - | 2 |
| SeaGreen | - | 2 |
| Sepia | - | 2 |
| SkyBlue | - | 2 |
| SpringGreen | - | 2 |
| Tan | - | 2 |
| TealBlue | - | 2 |
| Thistle | - | 2 |
| Turquoise | - | 2 |
| Violet | - | 2 |
| VioletRed | - | 2 |
| White | - | 2 |
| WildStrawberry | - | 2 |
| Yellow | - | 2 |
| YellowGreen | - | 2 |
| YellowOrange | - | 2 |

1. [Eindhoven University of Technology](http://www.tue.nl)
2. [LaTeX xcolor (dvipsnames)](https://en.wikibooks.org/wiki/LaTeX/Colors)

# Available colorcycles

## Xterm

| Name | Inverse colormap |
|----------|------------------|
| xterm | xterm_r |
| Name | Inverse colormap |
|-------|------------------|
| xterm | xterm_r |

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

| Name | Inverse colormap |
|--------------|------------------|
| tue | tue_r |
| tuedarkblue | - |
| tueblue | - |
| tuelightblue | - |
| tuewarmred | - |
| Name | Inverse colormap |
|------|------------------|
| tue | tue_r |


> Based on the corporate color scheme of the
> [Eindhoven University of Technology](http://www.tue.nl).
Binary file modified examples/overview/monocolor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/overview/monocolor_dvips_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/overview/monocolor_dvips_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions examples/overview/order_dvips.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import cppcolormap as cm
import numpy as np

names = (
"Apricot",
"Aquamarine",
"Bittersweet",
"Black",
"Blue",
"BlueGreen",
"BlueViolet",
"BrickRed",
"Brown",
"BurntOrange",
"CadetBlue",
"CarnationPink",
"Cerulean",
"CornflowerBlue",
"Cyan",
"Dandelion",
"DarkOrchid",
"Emerald",
"ForestGreen",
"Fuchsia",
"Goldenrod",
"Gray",
"Green",
"GreenYellow",
"JungleGreen",
"Lavender",
"LimeGreen",
"Magenta",
"Mahogany",
"Maroon",
"Melon",
"MidnightBlue",
"Mulberry",
"NavyBlue",
"OliveGreen",
"Orange",
"OrangeRed",
"Orchid",
"Peach",
"Periwinkle",
"PineGreen",
"Plum",
"ProcessBlue",
"Purple",
"RawSienna",
"Red",
"RedOrange",
"RedViolet",
"Rhodamine",
"RoyalBlue",
"RoyalPurple",
"RubineRed",
"Salmon",
"SeaGreen",
"Sepia",
"SkyBlue",
"SpringGreen",
"Tan",
"TealBlue",
"Thistle",
"Turquoise",
"Violet",
"VioletRed",
"WildStrawberry",
"Yellow",
"YellowGreen",
"YellowOrange")

dvips = np.array([list(cm.colormap(name, 1)[0, :]) for name in names])
jet = cm.jet(256)


idx = cm.match(dvips, jet, cm.metric.perceptual)
jdx = np.argsort(idx)
print('\n'.join([names[i] for i in jdx]))
72 changes: 69 additions & 3 deletions examples/overview/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,80 @@
"jet"),
'monocolor' : (
"White",
"Gray",
"Grey",
"Black",
"Red",
"Blue",
"Green",
"Yellow",
"Purple",
"Cyan",
"Orange",
"tuewarmred",
"tuedarkblue",
"tueblue",
"tuelightblue")}
"tuelightblue"),
'monocolor - dvips (1)' : (
"Plum",
"Fuchsia",
"BlueViolet",
"Violet",
"RoyalPurple",
"MidnightBlue",
"NavyBlue",
"RoyalBlue",
"CadetBlue",
"Periwinkle",
"PineGreen",
"Cerulean",
"JungleGreen",
"Emerald",
"TealBlue",
"CornflowerBlue",
"ProcessBlue",
"Aquamarine",
"BlueGreen",
"Turquoise",
"SkyBlue",
"SeaGreen",
"ForestGreen",
"OliveGreen",
"YellowGreen",
"LimeGreen",
"SpringGreen",
"GreenYellow"),
'monocolor - dvips (2)' : (
"Goldenrod",
"Dandelion",
"Apricot",
"YellowOrange",
"Lavender",
"Melon",
"Tan",
"Peach",
"BurntOrange",
"Salmon",
"Thistle",
"CarnationPink",
"Orchid",
"RedOrange",
"VioletRed",
"Rhodamine",
"DarkOrchid",
"Bittersweet",
"WildStrawberry",
"OrangeRed",
"Magenta",
"RubineRed",
"BrickRed",
"Maroon",
"Mulberry",
"Mahogany",
"RedViolet",
"RawSienna",
"Sepia",
"Brown")}

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

plt.savefig(cmap_category + '.png')
plt.savefig(cmap_category.replace(' ', '_').replace('(','').replace(')','').replace('_-_', '_') + '.png')
plt.close()

for cmap_category, cmap_list in cmaps.items():
Expand Down Expand Up @@ -116,7 +182,7 @@ def plot_color_gradients(cmap_category, cmap_list, nrows):
for ax in axes:
ax.set_axis_off()

plt.savefig(cmap_category + '.png')
plt.savefig(cmap_category.replace(' ', '_').replace('(','').replace(')','').replace('_-_', '_') + '.png')
plt.close()

plot_color_gradients('Colorcycles', cmaps, nrows)
Expand Down
Loading

0 comments on commit 7a29f48

Please sign in to comment.