Colormap is a Java package for creating and using colormaps. It includes many "reference" colormaps, including those from Matplotlib , Tableau and other sources (see credits).
- The main access to the colormaps is through
net.mahdilamb.colormap.Colormaps
. This includes a lot of wrapper classes and the ability to list the reference colormapsColormaps.named()
. - The wrapper classes include a reversed colormap (
Colormaps.reversedColormap()
), as well as a "fluid" colormapColormaps.fluidColormap()
. A fluid colormap is not, unlike the reference colormaps, limited to the range 0-1. Instead, a fluid colormap can autoscale, or be clamped between a min and max value (seenet.mahdilamb.colormap.FluidColormap
for more information). Fluid colormaps can also have the backing colormap changed.
Reference colormaps can either be accessed through Colormaps.get(String)
, which can take a String such as "sequential.viridis"
, "viridis"
or "sequential.viridis.reversed"
. Alternatively, they can be accessed using a class path embedded in the Colormaps class e.g. Colormaps.Sequential.Viridis()
(and then, for exampled made fluid Colormaps.fluidColormap(Colormaps.Sequential.Viridis())
).
Colormaps can be created in two ways either using a builder Colormaps.buildSequential()
and Colormaps.buildQualitative()
, or by extending net.mahdilamb.colormap.SequentialColormap
and net.mahdilamb.colormap.QualitativeColormap
. Reference colormaps are created by the latter approach.
As the fluid colormaps are autoranging, they fire an even when the color is changed. The below example shows how this might be done using a lambda expression. The original value is 0
, but this changes when a new color is requested from the colormap, and the range is changed, and a new event is triggered.
import net.mahdilamb.colormap.Colormaps;
import net.mahdilamb.colormap.FluidColormap;
public class Test {
public static void main(final String[] args) {
final FluidColormap viridis = Colormaps.fluidColormap(Colormaps.get("Viridis"));
viridis.get(0f, color -> {
System.out.println(color);
});
viridis.get(-1);
}
}
The colormap package includes a Colors utility class net.mahdilamb.colormap.Colors
. It holds constants for the colors specified in CSS4, AWT and Tableau.
It is possible to also include the xkcd colors. The addition of the colors is done automatically from text files in src\test\java\net\mahdilamb\colormap\reflect\InsertColors.java
. Uncomment the line referring to the xkcd file parsing and add an extra method in the Color class.
public static Color getXKCD(String name) {
return get(ColorType.XKCD, name);
}
The package can be imported from maven.
Category | ColorMap | Sample | Source |
---|---|---|---|
Cyclic | Edge | Paraview | |
Cyclic | HSV | ||
Cyclic | IceFire | Paraview | |
Cyclic | MRYBM | CET | |
Cyclic | MYGBM | CET | |
Cyclic | Phase | CMOcean | |
Cyclic | Twilight | matplotlib | |
Cyclic | TwilightShifted | matplotlib | |
Diverging | ArmyRose | CARTO | |
Diverging | Balance | CMOcean | |
Diverging | BentCoolWarm | Kenneth Moreland | |
Diverging | BrBG | ColorBrewer | |
Diverging | Curl | CMOcean | |
Diverging | Delta | CMOcean | |
Diverging | Diff | CMOcean | |
Diverging | Earth | CARTO | |
Diverging | Fall | CARTO | |
Diverging | Geyser | CARTO | |
Diverging | Oxy | CMOcean | |
Diverging | Picnic | Plotly | |
Diverging | PiYG | ColorBrewer | |
Diverging | Portland | Plotly | |
Diverging | PRGn | ColorBrewer | |
Diverging | PuOr | ColorBrewer | |
Diverging | RdBu | ColorBrewer | |
Diverging | RdGy | ColorBrewer | |
Diverging | RdYlBu | ColorBrewer | |
Diverging | RdYlGn | ColorBrewer | |
Diverging | SmoothCoolWarm | Kenneth Moreland | |
Diverging | Spectral | ColorBrewer | |
Diverging | TealRose | CARTO | |
Diverging | Temps | CARTO | |
Diverging | Topo | CMOcean | |
Diverging | Tropic | CARTO | |
Qualitative | Accent | ColorBrewer | |
Qualitative | Alphabet | Polychrome | |
Qualitative | Antique | CARTO | |
Qualitative | Bold | CARTO | |
Qualitative | D3 | d3.js | |
Qualitative | Dark2 | ColorBrewer | |
Qualitative | Dark24 | Polychrome | |
Qualitative | G10 | Plotly | |
Qualitative | Light24 | Polychrome | |
Qualitative | Paired | ColorBrewer | |
Qualitative | Pastel | CARTO | |
Qualitative | Pastel1 | ColorBrewer | |
Qualitative | Pastel2 | ColorBrewer | |
Qualitative | Plotly | Plotly | |
Qualitative | Prism | CARTO | |
Qualitative | Safe | CARTO | |
Qualitative | Set1 | ColorBrewer | |
Qualitative | Set2 | ColorBrewer | |
Qualitative | Set3 | ColorBrewer | |
Qualitative | T10 | Plotly | |
Qualitative | Tab10 | Tableau | |
Qualitative | Tab20 | Tableau | |
Qualitative | Tab20b | Tableau | |
Qualitative | Tab20c | Tableau | |
Qualitative | Vivid | CARTO | |
Sequential | AgGrnYl | Plotly | |
Sequential | AgSunset | Plotly | |
Sequential | Algae | CMOcean | |
Sequential | Amp | CMOcean | |
Sequential | BlackBody | Kenneth Moreland | |
Sequential | BlackbodyAlt | Plotly | |
Sequential | BlackBodyExtended | Kenneth Moreland | |
Sequential | Blues | ColorBrewer | |
Sequential | BluGrn | CARTO | |
Sequential | BluYl | CARTO | |
Sequential | BrwnYl | CARTO | |
Sequential | BuGn | ColorBrewer | |
Sequential | BuPu | ColorBrewer | |
Sequential | Burg | CARTO | |
Sequential | BurgYl | CARTO | |
Sequential | Cividis | matplotlib | |
Sequential | CubeYF | MyCarta | |
Sequential | DarkMint | CARTO | |
Sequential | Deep | CMOcean | |
Sequential | Dense | CMOcean | |
Sequential | Electric | Plotly | |
Sequential | Emrld | CARTO | |
Sequential | GnBu | ColorBrewer | |
Sequential | Gray | CMOcean | |
Sequential | Greens | ColorBrewer | |
Sequential | Greys | ColorBrewer | |
Sequential | Haline | CMOcean | |
Sequential | Hesperia | Peter Karpov | |
Sequential | Hot | Plotly | |
Sequential | Ice | CMOcean | |
Sequential | Inferno | matplotlib | |
Sequential | Jet | ||
Sequential | Kindlmann | Kindlmann et al. | |
Sequential | KindlmannExtended | Kindlmann et al. | |
Sequential | KovesiBGYW | CET | |
Sequential | KovesiKRYW | CET | |
Sequential | Lacerta | Peter Karpov | |
Sequential | Laguna | Peter Karpov | |
Sequential | Magenta | CARTO | |
Sequential | Magma | matplotlib | |
Sequential | Matter | CMOcean | |
Sequential | Mint | CARTO | |
Sequential | Oranges | ColorBrewer | |
Sequential | OrRd | ColorBrewer | |
Sequential | OrYel | CARTO | |
Sequential | Peach | CARTO | |
Sequential | PinkYl | CARTO | |
Sequential | Plasma | matplotlib | |
Sequential | PlasmaModified | Peter Karpov | |
Sequential | Plotly3 | Plotly | |
Sequential | PuBu | ColorBrewer | |
Sequential | PuBuGn | ColorBrewer | |
Sequential | PuRd | ColorBrewer | |
Sequential | Purp | CARTO | |
Sequential | Purples | ColorBrewer | |
Sequential | PurpOr | CARTO | |
Sequential | Rain | CMOcean | |
Sequential | RdPu | ColorBrewer | |
Sequential | RedOr | CARTO | |
Sequential | Reds | ColorBrewer | |
Sequential | Solar | CMOcean | |
Sequential | Speed | CMOcean | |
Sequential | Sunset | CARTO | |
Sequential | SunsetDark | CARTO | |
Sequential | Tarn | CMOcean | |
Sequential | Teal | CARTO | |
Sequential | TealGrn | CARTO | |
Sequential | Tempo | CMOcean | |
Sequential | Thermal | CMOcean | |
Sequential | Turbid | CMOcean | |
Sequential | Turbo | Google AI | |
Sequential | Viridis | matplotlib | |
Sequential | YlGn | ColorBrewer | |
Sequential | YlGnBu | ColorBrewer | |
Sequential | YlOrBr | ColorBrewer | |
Sequential | YlOrRd | ColorBrewer |
- Default colormaps include all ColorBrewer 2.0 color maps;
- Smooth Cool Warm, Bent Cool Warm, Black Body, Kindlmann, Extended Kindlmann (https://www.kennethmoreland.com/color-advice/)
- Tableau colour maps
- Colormaps from Peter Karpov.
- Turbo from https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
- "Why We Use Bad Color Maps and What You Can Do About It." Kenneth Moreland.
- "Beautiful colormaps for oceanography