From 534d89bac12d020bfc2846682fc973152a266334 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Wed, 28 Aug 2024 09:27:22 +0000 Subject: [PATCH] build based on d801a9f --- dev/.documenter-siteinfo.json | 2 +- dev/assets/colorschemes-docs.css | 15 ++- dev/assets/documenter.js | 53 +++++---- dev/basics/index.html | 183 ++++++++++++++++++++++++++----- dev/catalogue/index.html | 4 +- dev/finding/index.html | 6 +- dev/functionindex/index.html | 2 +- dev/goodpractice/index.html | 2 +- dev/images/index.html | 4 +- dev/index.html | 12 +- dev/objects.inv | Bin 1178 -> 1182 bytes dev/plotting/index.html | 4 +- dev/references/index.html | 2 +- dev/search_index.js | 2 +- 14 files changed, 221 insertions(+), 70 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index a8acb76..a766a4a 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-21T11:43:43","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-08-28T09:27:08","documenter_version":"1.6.0"}} \ No newline at end of file diff --git a/dev/assets/colorschemes-docs.css b/dev/assets/colorschemes-docs.css index 4b4043d..9c2e307 100644 --- a/dev/assets/colorschemes-docs.css +++ b/dev/assets/colorschemes-docs.css @@ -9,6 +9,7 @@ --lessdark: hsl(237, 20%, 16%); } + html.theme--documenter-dark body { background-color: var(--verydark); color: #eff; @@ -83,8 +84,16 @@ html.theme--documenter-dark .modal-card-head { font-family: "JuliaMono"; } +/* +is this how to scale the SVGs to page width? +*/ .swatch { - + width: 100%; + height: 100%; +} +.swatch svg { + width: 100%; + height: 100%; } .category { @@ -93,7 +102,7 @@ html.theme--documenter-dark .modal-card-head { } html.theme--documenter-dark p > code { - color: #eff !important; + color: #eff !important; } @@ -107,7 +116,7 @@ html.theme--documenter-dark a > code { } html.theme--documenter-dark p > a { - color: #eff !important; + color: #eff !important; } html.theme--documenter-dark .select select:focus, diff --git a/dev/assets/documenter.js b/dev/assets/documenter.js index b2bdd43..82252a1 100644 --- a/dev/assets/documenter.js +++ b/dev/assets/documenter.js @@ -77,30 +77,35 @@ require(['jquery'], function($) { let timer = 0; var isExpanded = true; -$(document).on("click", ".docstring header", function () { - let articleToggleTitle = "Expand docstring"; - - debounce(() => { - if ($(this).siblings("section").is(":visible")) { - $(this) - .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-down") - .addClass("fa-chevron-right"); - } else { - $(this) - .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-right") - .addClass("fa-chevron-down"); +$(document).on( + "click", + ".docstring .docstring-article-toggle-button", + function () { + let articleToggleTitle = "Expand docstring"; + const parent = $(this).parent(); + + debounce(() => { + if (parent.siblings("section").is(":visible")) { + parent + .find("a.docstring-article-toggle-button") + .removeClass("fa-chevron-down") + .addClass("fa-chevron-right"); + } else { + parent + .find("a.docstring-article-toggle-button") + .removeClass("fa-chevron-right") + .addClass("fa-chevron-down"); - articleToggleTitle = "Collapse docstring"; - } + articleToggleTitle = "Collapse docstring"; + } - $(this) - .find(".docstring-article-toggle-button") - .prop("title", articleToggleTitle); - $(this).siblings("section").slideToggle(); - }); -}); + parent + .children(".docstring-article-toggle-button") + .prop("title", articleToggleTitle); + parent.siblings("section").slideToggle(); + }); + } +); $(document).on("click", ".docs-article-toggle-button", function (event) { let articleToggleTitle = "Expand docstring"; @@ -110,7 +115,7 @@ $(document).on("click", ".docs-article-toggle-button", function (event) { debounce(() => { if (isExpanded) { $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); - $(".docstring-article-toggle-button") + $("a.docstring-article-toggle-button") .removeClass("fa-chevron-down") .addClass("fa-chevron-right"); @@ -119,7 +124,7 @@ $(document).on("click", ".docs-article-toggle-button", function (event) { $(".docstring section").slideUp(animationSpeed); } else { $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); - $(".docstring-article-toggle-button") + $("a.docstring-article-toggle-button") .removeClass("fa-chevron-right") .addClass("fa-chevron-down"); diff --git a/dev/basics/index.html b/dev/basics/index.html index 3fec790..9e2f6ac 100644 --- a/dev/basics/index.html +++ b/dev/basics/index.html @@ -1,5 +1,44 @@ -Basic usage · ColorSchemes

Basics

ColorScheme objects

When you start using ColorSchemes, it loads a set of pre-defined ColorSchemes in a dictionary called colorschemes.

A ColorScheme is a Julia object which contains:

  • an array of colors (eg RGB(0.1, 0.3, 0.4))
  • a string defining a category
  • a string that can contain descriptive notes

To access one of these built-in colorschemes, use its symbol:

ColorSchemes.leonardo # or colorschemes[:leonardo]
{ anchor.addEventListener('click', e => { e.preventDefault(); const redact = new URLSearchParams(window.location.search).get('redact'); const hasExistingParams = anchor.href.includes('?'); window.location.href = anchor.href + (hasExistingParams ? `&redact=${redact}` : `?redact=${redact}`); }); }); });

Basics

ColorScheme objects

When you start using ColorSchemes, it loads a set of pre-defined ColorSchemes in a dictionary called colorschemes.

A ColorScheme is a Julia object which contains:

  • an ordered array of colors (see Colors.jl)
  • a string defining a category
  • a string containing descriptive notes

To access one of the built-in colorschemes, use its symbol:

ColorSchemes.leonardo

or

colorschemes[:leonardo]
+ + + + + + + + + + + + + + + + +'/>

See below for more possibilities.

The colorschemes dictionary

The ColorSchemes module automatically provides a number of predefined schemes. All the colorschemes are stored in an exported dictionary, called colorschemes.

colorschemes[:summer] |> show
     ColorScheme(
         ColorTypes.RGB{Float64}[
             RGB{Float64}(0.0,0.5,0.4),
@@ -101,7 +161,7 @@
   botticelli                (notes) palette from artist Sandro Bot...
 
 
- ...found 6 results for "ice"

The function returns a list of matching colorscheme names as symbols.

ColorSchemes.findcolorschemeFunction
findcolorscheme(str;
+ ...found 6 results for "ice"

The function returns a list of matching colorscheme names as symbols.

ColorSchemes.findcolorschemeFunction
findcolorscheme(str;
     search_notes=true)

Find all colorschemes matching str. str is interpreted as a regular expression (case-insensitive).

This returns an array of symbols which are the names of matching schemes in the colorschemes dictionary.

julia> findcolorscheme("ice")
 
 colorschemes containing "ice"
@@ -114,15 +174,14 @@
   botticelli            (notes) palette from artist Sandro Bot...
 
 
- ...found 6 results for "ice"

To read the notes of a built-in colorscheme cscheme:

colorschemes[:cscheme].notes
source

If you prefer, you can ‘roll your own’ search.

[k for (k, v) in ColorSchemes.colorschemes if occursin(r"colorbrew"i, v.category)]
+ ...found 6 results for "ice"

To read the notes of a built-in colorscheme cscheme:

colorschemes[:cscheme].notes
source

If you prefer, you can ‘roll your own’ search.

[k for (k, v) in ColorSchemes.colorschemes if occursin(r"colorbrew"i, v.category)]
 265-element Array{Symbol,1}:
  :BuPu_6
  :Spectral_4
  :RdYlGn_5
  ⋮
  :BrBG_8
- :Oranges_4

Make your own colorscheme

Using Colors.jl, you can quickly define a range of colors and use it to make a colorscheme:

using Colors, ColorSchemes
-cs1 = ColorScheme(range(colorant"red", colorant"green", length=5))
-'/>
using Colors, ColorSchemes
-cs1 = ColorScheme(reverse(Colors.sequential_palette(300, 100, logscale=true)))

Using get():

cs1 = ColorScheme(get(ColorSchemes.darkrainbow, range(0.3, 0.7, length=10)))

Converting from a sequential palette:

cs1 = ColorScheme(reverse(Colors.sequential_palette(300, 100, logscale=true)))

Or you can easily make your own by building an array:

using Colors, ColorSchemes
-mygrays = ColorScheme([RGB{Float64}(i, i, i) for i in 0:0.1:1.0])

From an array comprehension:

mygrays = ColorScheme([RGB{Float64}(i, i, i) for i in 0:0.1:1.0])

A logarithmic scheme:

ColorScheme(get(ColorSchemes.darkrainbow, 10 .^ range(-2, stop=0, length=50)))

Give it a category or some added notes if you want:

mygrays = ColorScheme([RGB{Float64}(i, i, i) for i in 0:0.1:1.0],
-    "my useful schemes", "just some dull grey shades")

although this scheme won’t end up in the colorschemes dictionary.

Another example, starting with a two-color scheme, then building a gradient from the first color to the other.

myscheme = ColorScheme([Colors.RGB(1.0, 0.0, 0.0), Colors.RGB(0.0, 1.0, 0.0)],
+    "my useful schemes", "just some dull grey shades")

although this scheme won’t be stored in the supplied colorschemes dictionary.

Another example: start with a two-color scheme, then building a gradient from the first color to the other.

myscheme = ColorScheme([Colors.RGB(1.0, 0.0, 0.0), Colors.RGB(0.0, 1.0, 0.0)],
                "custom", "twotone, red and green")
-ColorScheme([get(myscheme, i) for i in 0.0:0.01:1.0])

Another way is to use the loadcolorscheme function:

using Colors
+ColorScheme([get(myscheme, i) for i in 0.0:0.01:1.0])

Another way is to use the loadcolorscheme function used to build the colorschemes dictionary when the package is loaded:

using Colors, ColorSchemes
 loadcolorscheme(:mygrays, [RGB{Float64}(i, i, i) for i in 0:0.1:1.0],
-     "useful schemes", "just some dull grey shades")

and that will be added (temporarily) to the built-in list.

julia> findcolorscheme("dull")
+     "useful schemes", "just some dull grey shades")

and that will be added (temporarily) to the built-in dictionary.

julia> findcolorscheme("dull")
 
 colorschemes containing "dull"
 
   mygrays               (notes) just some dull grey shades...
 
 
- ...found 1 result for "dull"

If you want to make more advanced ColorSchemes, use linear-segment dictionaries or indexed lists, and use functions to generate color values, see the make_colorscheme() function in the ColorSchemeTools.jl package.

For CVD (color-vision deficient or "color-blind") users

This package contains a number of colorschemes that are designed to be helpful for people with some deficiencies in their perception of color:

  • deuteranomaly (where green looks more red)

  • protanomaly (where red looks more green and less bright)

  • tritanomaly (difficult to tell the difference between blue and green, and between yellow and red)

  • tritanopia (difficult to tell the difference between blue and green, purple and red, and yellow and pink)

findcolorscheme("cvd")
+ ...found 1 result for "dull"
Note

If you want to make more advanced ColorSchemes, use linear-segment dictionaries or indexed lists, and use functions to generate color values, see the make_colorscheme() function in the ColorSchemeTools.jl package.

For CVD (color-vision deficient or "color-blind") users

This package contains a number of colorschemes that are designed to be helpful for people with some deficiencies in their perception of color:

  • deuteranomaly (where green looks more red)

  • protanomaly (where red looks more green and less bright)

  • tritanomaly (difficult to tell the difference between blue and green, and between yellow and red)

  • tritanopia (difficult to tell the difference between blue and green, purple and red, and yellow and pink)

findcolorscheme("cvd")
 
 colorschemes containing "cvd"
 
@@ -418,7 +549,7 @@
 
 
 
-'/>

Continuous color sampling

You can access the specific colors of a colorscheme by indexing (eg leonardo[2] or leonardo[5:end]). Or you can sample a ColorScheme at a point between 0.0 and 1.0 as if it were a continuous range of colors:

get(leonardo, 0.5)

returns

RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)

"get example"

The colors in the predefined ColorSchemes are usually sorted by LUV luminance, so this often makes sense.

You can use get() with index data in arrays to return arrays of colors:

julia> get(leonardo, [0.0, 0.5, 1.0])
+'/>

More about color sampling

You can access the specific colors of a colorscheme by indexing (eg leonardo[2] or leonardo[5:end]). Or you can sample a ColorScheme at a point between 0.0 and 1.0 as if it were a continuous range of colors:

get(leonardo, 0.5)

returns

RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)

"get example"

The colors in the predefined ColorSchemes are usually sorted by LUV luminance, so this often makes sense.

You can use get() with index data in arrays to return arrays of colors:

julia> get(leonardo, [0.0, 0.5, 1.0])
 3-element Array{RGB{Float64},1} with eltype ColorTypes.RGB{Float64}:
  RGB{Float64}(0.05482025926320272,0.016508952654741622,0.019315160361063788)
  RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)  
@@ -476,4 +607,4 @@
     return ColorScheme([RGBA(get(cscheme, k), alpha) for k in range(0, 1, length=ncolors)])
 end
 
-colors = colorscheme_alpha(ColorSchemes.ice, ncolors=12)
+colors = colorscheme_alpha(ColorSchemes.ice, ncolors=12)
diff --git a/dev/catalogue/index.html b/dev/catalogue/index.html index bb078f9..b7f1e62 100644 --- a/dev/catalogue/index.html +++ b/dev/catalogue/index.html @@ -1,5 +1,5 @@ -Catalogue · ColorSchemes

Catalogue of ColorSchemes

At the REPL you can search for colorschemes by name:

findcolorscheme("julia")

✦ cmocean

From "Beautiful colormaps for oceanography": cmocean

+Catalogue · ColorSchemes

Catalogue of ColorSchemes

At the REPL you can search for colorschemes by name:

findcolorscheme("julia")

✦ cmocean

From "Beautiful colormaps for oceanography": cmocean

@@ -93650,4 +93650,4 @@

« IntroductionBasic usage »

+
diff --git a/dev/finding/index.html b/dev/finding/index.html index 684c68a..01b6050 100644 --- a/dev/finding/index.html +++ b/dev/finding/index.html @@ -1,5 +1,5 @@ -Finding colors · ColorSchemes

Finding colors in colorschemes

ColorSchemes.jl provides the function getinverse(cscheme, color) which is the inverse of get(cscheme, n). This function returns a number between 0 and 1 that best represents the location of a color on the colorscheme's 'axis'.

"get inverse"

ColorSchemes.getinverseFunction
getinverse(cscheme::ColorScheme, c, range=(0.0, 1.0))

Computes where the provided Color c would fit in cscheme.

This is the inverse of get() — it returns the value x in the provided range for which get(scheme, x) would most closely match the provided Color c.

Examples

The first example asks: "where in the leonardo colorscheme will I find the nearest color to red?":

julia> getinverse(colorschemes[:leonardo], RGB(1, 0, 0))
+Finding colors · ColorSchemes        
         
 

Finding colors in colorschemes

ColorSchemes.jl provides the function getinverse(cscheme, color) which is the inverse of get(cscheme, n). This function returns a number between 0 and 1 that best represents the location of a color on the colorscheme's 'axis'.

"get inverse"

ColorSchemes.getinverseFunction
getinverse(cscheme::ColorScheme, c, range=(0.0, 1.0))

Computes where the provided Color c would fit in cscheme.

This is the inverse of get() — it returns the value x in the provided range for which get(scheme, x) would most closely match the provided Color c.

Examples

The first example asks: "where in the leonardo colorscheme will I find the nearest color to red?":

julia> getinverse(colorschemes[:leonardo], RGB(1, 0, 0))
 0.6248997995654847
 
 julia> getinverse(ColorScheme([Colors.RGB(0,0,0), Colors.RGB(1,1,1)]),  Colors.RGB(.5,.5,.5))
@@ -8,7 +8,7 @@
 julia> cs = ColorScheme(range(Colors.RGB(0,0,0), stop=Colors.RGB(1,1,1), length=5))
 
 julia> getinverse(cs, cs[3])
-0.5
source

Example of using getinverse()

One example use for getinverse() is to convert a heatmap image into an Array of continuous values, e.g. temperature.

In this example, we will convert a heatmap image representing temperature into an array of elevation values. The image represents global temperature anomalies averaged from 2008 through 2012, with blue as -2°C and Red as +2°C. Higher than normal temperatures are shown in red (red is +2°C) and lower than normal temperatures are shown in blue (blue is -2°C). The global surface temperature in 2012 was +0.55°C.

NASA archive source.

using Images, FileIO, Downloads, ColorSchemes
+0.5
source

Example of using getinverse()

One example use for getinverse() is to convert a heatmap image into an Array of continuous values, e.g. temperature.

In this example, we will convert a heatmap image representing temperature into an array of elevation values. The image represents global temperature anomalies averaged from 2008 through 2012, with blue as -2°C and Red as +2°C. Higher than normal temperatures are shown in red (red is +2°C) and lower than normal temperatures are shown in blue (blue is -2°C). The global surface temperature in 2012 was +0.55°C.

NASA archive source.

using Images, FileIO, Downloads, ColorSchemes
 img = Downloads.download("https://www.giss.nasa.gov/research/news/archive/20130115/719282main_2008_2012_printdata.1462.jpg") |> load
 img = imresize(img, Tuple(Int(x) for x in size(img) .* 0.2));
 display(img)

"heatmap 1"

temps = [getinverse(ColorSchemes.temperaturemap, pixel) for pixel in img]
@@ -53,4 +53,4 @@
     label("largest positive anomaly", :E, maxpt, offset=20)
     circle(minpt, 5, :fill)
     label("largest negative anomaly", :E, minpt, offset=20)
-end 800 460

"heatmap min and max"

We can display the array of continuous values as a grayscale image, where black is 0.0 and white is 1.0.

Gray.(temps)

"heatmap 2 grey"

+end 800 460

"heatmap min and max"

We can display the array of continuous values as a grayscale image, where black is 0.0 and white is 1.0.

Gray.(temps)

"heatmap 2 grey"

diff --git a/dev/functionindex/index.html b/dev/functionindex/index.html index 07bd54c..bfa6b96 100644 --- a/dev/functionindex/index.html +++ b/dev/functionindex/index.html @@ -1,2 +1,2 @@ -Index · ColorSchemes
+Functions · ColorSchemes
diff --git a/dev/goodpractice/index.html b/dev/goodpractice/index.html index 007a5e7..017bfba 100644 --- a/dev/goodpractice/index.html +++ b/dev/goodpractice/index.html @@ -1,2 +1,2 @@ -Good practice · ColorSchemes

Good practice

There are hundreds of colorschemes in this package, and they're useful for many different purposes. However, if you're intending to use a colorscheme for communicating features of a scientific dataset, you should choose it with care.

Perceptual uniformity

You should choose a perceptually uniform colorscheme: a set of colors arranged so that equal steps in data are perceived by the viewer as equal steps in the color space.

Researchers[Kovesi][ZhouHansen] have found that the human brain perceives changes in the lightness parameter as changes in the data much better than, for example, changes in hue. So sequential colorschemes with monotonically increasing lightness values will be better interpreted by the viewer.

The Lab color space represents a color with three components: Lightness, RedGreen, and YellowBlue. The Lightness parameter can be used to indicate how uniform the colors will be perceived by viewers.

In the following diagrams, the Lightness Lab component of each color step is plotted in y as x moves through the colorscheme. You can see how the lightness increases evenly in the recommended schemes.

Sequential

Good choices include viridis, inferno, plasma, magma:

Example block outputExample block output

ColorCET schemes (findcolorscheme("colorcet") will return the very long names to save you typing them):

Example block output

Fabio Crameri's Scientific colorschemes:

Example block outputExample block output

Diverging

For diverging colorschemes, the lightness values of the extremes should be broadly equivalent. As well as the diverging- ColorCET colorschemes, there are suitable schemes in Scientific, ColorBrewer, and others.

Example block outputExample block outputExample block output

Less suitable for data visualization

Colorschemes with rapid changes in lightness are less suitable, because the viewer's interpretation of a region of data might be influenced by the coloring, rather than by the data values.

Example block outputExample block outputExample block output

References

  • KovesiGood Colour Maps: How to Design Them | Peter Kovesi | arXiv:1509.03700 [cs.GR] | https://doi.org/10.48550/arXiv.1509.03700
  • ZhouHansenA Survey of Colormaps in Visualization | Liang Zhou, Charles D Hansen | https://pubmed.ncbi.nlm.nih.gov/26513793/
+Good practice · ColorSchemes

Good practice

There are hundreds of colorschemes in this package, and they're useful for many different purposes. However, if you're intending to use a colorscheme for communicating features of a scientific dataset, you should choose it with care.

Perceptual uniformity

You should choose a perceptually uniform colorscheme: a set of colors arranged so that equal steps in data are perceived by the viewer as equal steps in the color space.

Researchers[Kovesi][ZhouHansen] have found that the human brain perceives changes in the lightness parameter as changes in the data much better than, for example, changes in hue. So sequential colorschemes with monotonically increasing lightness values will be better interpreted by the viewer.

The Lab color space represents a color with three components: Lightness, RedGreen, and YellowBlue. The Lightness parameter can be used to indicate how uniform the colors will be perceived by viewers.

In the following diagrams, the Lightness Lab component of each color step is plotted in y as x moves through the colorscheme. You can see how the lightness increases evenly in the recommended schemes.

Sequential

Good choices include viridis, inferno, plasma, magma:

Example block outputExample block output

ColorCET schemes (findcolorscheme("colorcet") will return the very long names to save you typing them):

Example block output

Fabio Crameri's Scientific colorschemes:

Example block outputExample block output

Diverging

For diverging colorschemes, the lightness values of the extremes should be broadly equivalent. As well as the diverging- ColorCET colorschemes, there are suitable schemes in Scientific, ColorBrewer, and others.

Example block outputExample block outputExample block output

Less suitable for data visualization

Colorschemes with rapid changes in lightness are less suitable, because the viewer's interpretation of a region of data might be influenced by the coloring, rather than by the data values.

Example block outputExample block outputExample block output

References

  • KovesiGood Colour Maps: How to Design Them | Peter Kovesi | arXiv:1509.03700 [cs.GR] | https://doi.org/10.48550/arXiv.1509.03700
  • ZhouHansenA Survey of Colormaps in Visualization | Liang Zhou, Charles D Hansen | https://pubmed.ncbi.nlm.nih.gov/26513793/
diff --git a/dev/images/index.html b/dev/images/index.html index c6521a6..bc9e93b 100644 --- a/dev/images/index.html +++ b/dev/images/index.html @@ -1,5 +1,5 @@ -Images · ColorSchemes

Images

A Julia Julia set: ColorSchemes and Images

Here's an example of how you can use ColorSchemes when creating images with Images.jl. The code creates a Julia set and uses a pre-defined ColorScheme extracted from Vermeer's painting "Girl with a Pearl Earring" (shown at the right for reference).

"julia set"

using ColorSchemes, Images, FileIO
+Images · ColorSchemes        
         
 

Images

A Julia Julia set: ColorSchemes and Images

Here's an example of how you can use ColorSchemes when creating images with Images.jl. The code creates a Julia set and uses a pre-defined ColorScheme extracted from Vermeer's painting "Girl with a Pearl Earring" (shown at the right for reference).

"julia set"

using ColorSchemes, Images, FileIO
 # and possibly QuartzImageIO (macOS) and/or ImageMagick (Linux)
 
 function julia(z, c, maxiter::Int64)
@@ -31,4 +31,4 @@
     save(filename, imOutput)
 end
 
-draw(-0.4 + 0.6im, 1200)
+draw(-0.4 + 0.6im, 1200)
diff --git a/dev/index.html b/dev/index.html index 5fac266..6c6f580 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,5 +1,5 @@ -Introduction · ColorSchemes

Introduction to ColorSchemes

This package provides a collection of colorschemes:

  • scientifically devised colorschemes from ColorBrewer, CMOcean, ScientificColorMaps, ColorCet, and Seaborn
  • popular favourites such as viridis, inferno, and magma from MATPlotLib
  • variously themed colorschemes such as sunset, coffee, neon, and pearl
  • artistic colorschemes, such as leonardo, vermeer, picasso, Degas, Hiroshige,

Note that the schemes contained here are a mixture:

  • some are high quality color maps with consistent perceptual contrast over their full range
  • others are designed for general purpose and informal graphics work

Choose colorschemes with care! See the Good practice section, and also refer to Peter Kovesi's PerceptualColourMaps package, or to Fabio Crameri's Scientific Colour Maps for technical information.

This package relies on the Colors.jl package.

If you want to make more advanced ColorSchemes, use linear-segment dictionaries or indexed lists, and use functions to generate color values, see the make_colorscheme() function in the ColorSchemeTools.jl package.

Installation and basic usage

Install the package as follows:

import Pkg
+Introduction · ColorSchemes        
         
 

Introduction to ColorSchemes

This package provides a collection of colorschemes:

  • scientifically devised colorschemes from ColorBrewer, CMOcean, ScientificColorMaps, ColorCet, and Seaborn
  • popular favourites such as viridis, inferno, and magma from MATPlotLib
  • variously themed colorschemes such as sunset, coffee, neon, and pearl
  • artistic colorschemes, such as leonardo, vermeer, picasso, Degas, Hiroshige,

Note that the schemes contained here are a mixture:

  • some are high quality color maps with consistent perceptual contrast over their full range
  • others are designed for general purpose and informal graphics work

Choose colorschemes with care! See the Good practice section, and also refer to Peter Kovesi's PerceptualColourMaps package, or to Fabio Crameri's Scientific Colour Maps for technical information.

This package relies on the Colors.jl package.

If you want to make more advanced ColorSchemes, use linear-segment dictionaries or indexed lists, and use functions to generate color values, see the make_colorscheme() function in the ColorSchemeTools.jl package.

Installation and basic usage

Install the package as follows:

import Pkg
 Pkg.add("ColorSchemes")

or, at the REPL:

] add ColorSchemes

Usage:

using ColorSchemes
 
 ColorSchemes.Purples_5 
@@ -21,7 +21,13 @@
 # => Dict{Symbol, ColorScheme} with 1150 entries
 
 findcolorscheme("purple")
-# => display list of matching schemes

Original version by cormullion.

Contributing a new colorscheme

If you think a new colorscheme would be a great addition for you and for Julians everywhere, you can contribute it as follows:

1 Add a file to the data/ directory. The file should be a Julia file, with a .jl suffix.

2 Inside the file, define a colorscheme in this format, which calls loadcolorscheme:

loadcolorscheme(:mynewcolorscheme, [
+# => display list of matching schemes
+
+ColorScheme([colorant"red", colorant"green", colorant"blue"])
+# new colorscheme from Colors.jl named colors
+
+get(ColorSchemes.darkrainbow, range(0.0, 1.0, length=20)) |> ColorScheme
+# new colorscheme by resampling existing

Original version by cormullion.

Contributing a new colorscheme

If you think a new colorscheme would be a great addition for you and for Julians everywhere, you can contribute it as follows:

1 Add a file to the data/ directory. The file should be a Julia file, with a .jl suffix.

2 Inside the file, define a colorscheme in this format, which calls loadcolorscheme:

loadcolorscheme(:mynewcolorscheme, [
     RGB(0.0, 0.0, 0.0),
     RGB(0.5, 0.5, 0.5),
     RGB(1.0, 1.0, 1.0),
@@ -31,4 +37,4 @@
     )

The new name - here mynewcolorscheme - should be a valid Julia variable name.

3 If you're adding the new colorscheme to an existing category, it will appear in the catalog document automatically.

4 Otherwise, to add a new category to the catalog (which will add all the colorschemes in that category), add this code to catalogue.md:

    ```@example catalog
     using Luxor, ColorSchemes # hide
     ColorSchemeCategory("category for my new scheme") # hide
-    ```

5 If there's a license file, add it to data/ as well.

Documentation

This documentation was built using Documenter.jl.

Documentation built 2024-07-21T11:43:40.246 with Julia 1.10.4
+ ```

5 If there's a license file, add it to data/ as well.

Documentation

This documentation was built using Documenter.jl.

Documentation built 2024-08-28T09:27:04.959 with Julia 1.10.5
diff --git a/dev/objects.inv b/dev/objects.inv index 68688dd32300b2a5af93af530aefd4bdaf4c2075..8096c6db4bbbd875839446dfc087314b3e79282f 100644 GIT binary patch delta 1067 zcmV+`1l0SQ37!d%f`8j?<2Dd|=T{6i36P+eHP*!fso$KW2~sqL(Y@p`pd{L6LW?d* zZPxvkKKH}=B^^?dMOv29zStIZ&LKH7JRHli5Z}SNVpixJ@B_eo>5ML_+(})soI9@c zsuD3|KRAKw_9x4@mAQ>!^~eOS{5MpVuLN6ZU2F{}@jQ`?$A2eqM^Df`vZX8wS*~Ju zGcC`K%>aZEcB>6uf4#x;porh3^+JVM%3M;qkjCECuP7X4@$LdED~vt9`Bv;~ zdO0k2Hl0R-^mI1;sSzbU5Fe7oz@82CI$aC|9$N^Li+`=FxWcNGOKmpN?Z(Tjqd-Tg zYiUzCQH+*SjX-wo*YYW30d@8)ayJl|Q;49@K-mL-5xCQpLH(Lk!jOn3fF}SE;u@fp zkSWQm@~0O$mg03-FRZ460|$a9YCnJHo2{ZfEh#ZxaU}@(jY2KXF9xb~ghS;(Ife!S zdIkXzC$2e@LW<^;BVTvH9iXK-Z;<=0RjO$f!zx3*1cj*m_I-Z zVmFeOx@x_1#J?y@@*w1Uiw%G|{!%H)n@=m;45RX}$jbunI|tsYG#-4?<5O$~73L6N z&8MF%u0;z3ZB6|_xGN)Gg?S^CdmOvt#Zv9Y_J11Y!mqUt-0Xc|Y3Qp^J3MNAy%}Q_ z=&L~Mgf}{`HuQ!EhdZo#WWNe)(N@y&j7pVGJr*>THySbm`R5VZVS2p+vv#UTa*ou(MfuDUkmhyx+}Qp#Kx z;(xzvajb^@`^C;ZXZB1dQX&EbLcMEf31R7% zV=KS(DJm^RP=&G$t`Q&@deI|w(}9C;WPefP`n#Z=(Ag^v@6NtKF5)J1AoC&cA4dcK zkzkLK)^vDgQ>C=$I#xwpG}A__DIni$W73lk?k(-hsg;?Whr@N{+m(wqT+fK5@KxuJ z2T{+aw{&rKbl)cR1cEsZO|!Sf{httjI}ck!a+>xWe_tmKL3bz4DbL0p2EKP3A0+(+ l)Ij5I$-eh}L)@V}t6AHsLTWe(t!o($7*V&3>|ax6#fR^F02KfL delta 1063 zcmV+?1laqY37QFzf`7|y<2DrC^D8bUF_56RF~-FJsdr8?2{M=|jLsv=fRbpN2`zd= zYBKJ(blnf@m-Lc)k(Q;j8_O2YIplrvTIQMf3C3pgOs9Zv0q%2K=&Vew)HzGJ;@l%v9EN2ngE^v zj=*jOx0_yFM9g2H0kIoNR+0eb=&E zmAYx4^!ViFL4^f)SpDfX3)9*FL7Q9PldxBXcz+SaE3RyD?2czEwI8$9?}gv0mU7d! zlvP2GOzrV#zwGT8sz6@_n)Z34({f8I+%?Qz0U`S+j6qXM%M;3aY9N@=R<37JPmzBf zp&f?TDL|tDqySCUdhMpfnFi>HJ zV1IVi%{4~~64}>WraBY<#l*23cI(T%QyEiO7BUn6$3LDByJn$w8;-W%x!LhT#X_T3s`HHx5(qx*L;v z0=}aSZPWI$_OFJ!ormi=DuI^c?(3+m>B7SW#knwtj_=jbgS$0qXgDpI3pY1}6Clcy hnm5xa#9e~Ah`69pVFVH>cT>dyBN&~L{R?mE#@W287ySSL diff --git a/dev/plotting/index.html b/dev/plotting/index.html index fbf2efa..151893a 100644 --- a/dev/plotting/index.html +++ b/dev/plotting/index.html @@ -1,5 +1,5 @@ -Plotting · ColorSchemes

Plotting

UnicodePlots.jl

The heatmap() function in UnicodePlots.jl can use colorschemes. You have to supply the colors as an array of floating-point numbers first:

... colormap = [(x.r, x.g, x.b) for x in ColorSchemes.leonardo.colors]

For example:

heatmap(z::AbstractMatrix; title = "Hot!",
+Plotting · ColorSchemes        
         
 

Plotting

UnicodePlots.jl

The heatmap() function in UnicodePlots.jl can use colorschemes. You have to supply the colors as an array of floating-point numbers first:

... colormap = [(x.r, x.g, x.b) for x in ColorSchemes.leonardo.colors]

For example:

heatmap(z::AbstractMatrix; title = "Hot!",
     colormap = [(x.r, x.g, x.b) for x in ColorSchemes.leonardo.colors])

"heatmap"

Plots.jl

Plots.jl supports all colorschemes from ColorSchemes.jl. They can be used as a gradient or as a palette and are passed as a symbol holding their name to cgrad or palette.

This renaissance-looking plot uses the leonardo scheme:

using Plots
 
 x = 1:0.3:20
@@ -85,4 +85,4 @@
     alpha=0.8,
     linewidth=0.25)
 
-display(fig)

"pyplot"

+display(fig)

"pyplot"

diff --git a/dev/references/index.html b/dev/references/index.html index 93d870c..d74a8f7 100644 --- a/dev/references/index.html +++ b/dev/references/index.html @@ -1,2 +1,2 @@ -References · ColorSchemes

References

✦ cmocean

From "Beautiful colormaps for oceanography": cmocean

✦ scientific

From Scientific colormaps

✦ matplotlib

From matplot

✦ colorbrewer

From ColorBrewer

✦ gnuplot

From GNUPlot

✦ colorcet

From "collection of perceptually accurate colormaps"

✦ Seaborn

From "colorschemes used by Seaborn, a Python data visualization library based on matplotlib."

✦ ggthemes/tableau

From "ggthemes tableau palettes"

✦ CVD/(ColorBlind)-friendly schemes

Colorschemes designed with color-vision deficient users in mind, by authors such as Paul Tol, Masataka Okabe, Kei Ito, and Martin Krzywinski.

✦ Flags

Colors extracted from flags of different countries and regions, downloaded from Flagpedia. Intended to represent these regions in visualizations, but not necessarily effective. Many flags have similar colorschemes. The flags are named according to the region's ISO3166 two-letter abbreviation (often the same as top-level WWW domain), with any hyphens removed.

✦ general and miscellaneous

+References · ColorSchemes

References

✦ cmocean

From "Beautiful colormaps for oceanography": cmocean

✦ scientific

From Scientific colormaps

✦ matplotlib

From matplot

✦ colorbrewer

From ColorBrewer

✦ gnuplot

From GNUPlot

✦ colorcet

From "collection of perceptually accurate colormaps"

✦ Seaborn

From "colorschemes used by Seaborn, a Python data visualization library based on matplotlib."

✦ ggthemes/tableau

From "ggthemes tableau palettes"

✦ CVD/(ColorBlind)-friendly schemes

Colorschemes designed with color-vision deficient users in mind, by authors such as Paul Tol, Masataka Okabe, Kei Ito, and Martin Krzywinski.

✦ Flags

Colors extracted from flags of different countries and regions, downloaded from Flagpedia. Intended to represent these regions in visualizations, but not necessarily effective. Many flags have similar colorschemes. The flags are named according to the region's ISO3166 two-letter abbreviation (often the same as top-level WWW domain), with any hyphens removed.

✦ general and miscellaneous

diff --git a/dev/search_index.js b/dev/search_index.js index 27f5fad..bed763c 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"functionindex/#Index","page":"Index","title":"Index","text":"","category":"section"},{"location":"functionindex/","page":"Index","title":"Index","text":"","category":"page"},{"location":"references/#References","page":"References","title":"References","text":"","category":"section"},{"location":"references/#cmocean","page":"References","title":"✦ cmocean","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From \"Beautiful colormaps for oceanography\": cmocean","category":"page"},{"location":"references/#scientific","page":"References","title":"✦ scientific","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From Scientific colormaps","category":"page"},{"location":"references/#matplotlib","page":"References","title":"✦ matplotlib","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From matplot","category":"page"},{"location":"references/#colorbrewer","page":"References","title":"✦ colorbrewer","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From ColorBrewer","category":"page"},{"location":"references/#gnuplot","page":"References","title":"✦ gnuplot","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From GNUPlot","category":"page"},{"location":"references/#colorcet","page":"References","title":"✦ colorcet","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From \"collection of perceptually accurate colormaps\"","category":"page"},{"location":"references/#Seaborn","page":"References","title":"✦ Seaborn","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From \"colorschemes used by Seaborn, a Python data visualization library based on matplotlib.\"","category":"page"},{"location":"references/#ggthemes/tableau","page":"References","title":"✦ ggthemes/tableau","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From \"ggthemes tableau palettes\"","category":"page"},{"location":"references/#CVD/(ColorBlind)-friendly-schemes","page":"References","title":"✦ CVD/(ColorBlind)-friendly schemes","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"Colorschemes designed with color-vision deficient users in mind, by authors such as Paul Tol, Masataka Okabe, Kei Ito, and Martin Krzywinski.","category":"page"},{"location":"references/#Flags","page":"References","title":"✦ Flags","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"Colors extracted from flags of different countries and regions, downloaded from Flagpedia. Intended to represent these regions in visualizations, but not necessarily effective. Many flags have similar colorschemes. The flags are named according to the region's ISO3166 two-letter abbreviation (often the same as top-level WWW domain), with any hyphens removed.","category":"page"},{"location":"references/#general-and-miscellaneous","page":"References","title":"✦ general and miscellaneous","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors\n\nfunction draw_lightness_swatch(cs::ColorScheme, width = 800, height=150;\n\t\tname=\"\")\n\t@drawsvg begin\n\t\thmargin= 30\n\t\tvmargin= 20\n\t\tbb = BoundingBox(Point(-width/2 + hmargin, -height/2 + vmargin), Point(width/2 - hmargin, height/2 - vmargin))\n\n\t\tbackground(\"black\")\n\t\tfontsize(8)\n\t\tsethue(\"white\")\n\t\tsetline(0.5)\n\t\tbox(bb, :stroke)\n\n\t\ttickline(boxbottomleft(bb), boxbottomright(bb), major = 9, axis=false,\n\t\t\tmajor_tick_function = (n, pos; startnumber, finishnumber, nticks) ->\n\t\t\t\ttext(string(n/10), pos + (0, 12), halign=:center)\n\t\t\t)\n\n\t\ttickline(boxbottomright(bb), boxtopright(bb), major = 9, axis=false,\n\t\t\tmajor_tick_function = (n, pos; startnumber, finishnumber, nticks) ->\n\t\t\t\ttext(string(10n), pos + (0, 20), angle=π/2, halign=:right, valign=:middle)\n\t\t\t)\n\n\t\ttext(\"lightness\", boxtopleft(bb) + (10, 10), halign=:right, angle=-π/2)\n\n\t\tfontsize(12)\n\t\tL = 70\n\t\tsw = width/L\n\t\tsaved = Point[]\n\t\tfor i in range(0.0, 1.0, length=L)\n\t\t\tpos = between(boxmiddleleft(bb), boxmiddleright(bb), i)\n\t\t\tcolor = get(cs, i)\n\t\t\tsetcolor(color)\n\t\t\tlabcolor = convert(Lab, color)\n\t\t\tlightness = labcolor.l\n\t\t\tlightnesspos = pos + (0, boxheight(bb)/2 - rescale(labcolor.l, 0, 100, 0, boxheight(bb)))\n\t\t\tpush!(saved, lightnesspos)\n\t\t\tcircle(lightnesspos, 5, :fill)\n\n\t\tend\n\n#\t\tsetline(1)\n#\t\tsethue(\"black\")\n#\t\tline(saved[1], saved[end], :stroke)\n#\t\tsetline(0.8)\n#\t\tline(saved[1], saved[end], :stroke)\n\n sethue(\"white\")\n\t\ttext(name, boxtopcenter(bb) + (0, -6), halign=:center)\n\tend width height\nend","category":"page"},{"location":"goodpractice/#Good-practice","page":"Good practice","title":"Good practice","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"There are hundreds of colorschemes in this package, and they're useful for many different purposes. However, if you're intending to use a colorscheme for communicating features of a scientific dataset, you should choose it with care.","category":"page"},{"location":"goodpractice/#Perceptual-uniformity","page":"Good practice","title":"Perceptual uniformity","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"You should choose a perceptually uniform colorscheme: a set of colors arranged so that equal steps in data are perceived by the viewer as equal steps in the color space.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"Researchers[Kovesi][ZhouHansen] have found that the human brain perceives changes in the lightness parameter as changes in the data much better than, for example, changes in hue. So sequential colorschemes with monotonically increasing lightness values will be better interpreted by the viewer.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"The Lab color space represents a color with three components: Lightness, RedGreen, and YellowBlue. The Lightness parameter can be used to indicate how uniform the colors will be perceived by viewers.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"In the following diagrams, the Lightness Lab component of each color step is plotted in y as x moves through the colorscheme. You can see how the lightness increases evenly in the recommended schemes.","category":"page"},{"location":"goodpractice/#Recommended","page":"Good practice","title":"Recommended","text":"","category":"section"},{"location":"goodpractice/#Sequential","page":"Good practice","title":"Sequential","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"Good choices include viridis, inferno, plasma, magma:","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.viridis, 400, 150 ; name=\"viridis\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.inferno, 400, 150 ; name=\"inferno\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.plasma, 400, 150 ; name=\"plasma\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.magma, 400, 150 ; name=\"magma\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"ColorCET schemes (findcolorscheme(\"colorcet\") will return the very long names to save you typing them):","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.linear_kbc_5_95_c73_n256, 400, 150 ; name=\"linear_kbc_5_95_c73_n256\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.linear_tritanopic_krjcw_5_95_c24_n256, 400, 150 ; name=\"linear_tritanopic_krjcw_5_95_c24_n256\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"Fabio Crameri's Scientific colorschemes:","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.tokyo, 400, 150 ; name=\"tokyo\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.devon, 400, 150 ; name=\"devon\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.hawaii, 400, 150 ; name=\"hawaii\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.buda, 400, 150 ; name=\"buda\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/#Diverging","page":"Good practice","title":"Diverging","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"For diverging colorschemes, the lightness values of the extremes should be broadly equivalent. As well as the diverging- ColorCET colorschemes, there are suitable schemes in Scientific, ColorBrewer, and others.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.RdBu, 400, 150 ; name=\"RdBu\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.BrBg, 400, 150 ; name=\"BrBg\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.RdBu, 400, 150 ; name=\"RdBu\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.BrBg, 400, 150 ; name=\"BrBg\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.diverging_bwr_55_98_c37_n256, 400, 150 ; name=\"diverging_bwr_55_98_c37_n256\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.diverging_rainbow_bgymr_45_85_c67_n256, 400, 150 ; name=\"diverging_rainbow_bgymr_45_85_c67_n256\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/#Less-suitable-for-data-visualization","page":"Good practice","title":"Less suitable for data visualization","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"Colorschemes with rapid changes in lightness are less suitable, because the viewer's interpretation of a region of data might be influenced by the coloring, rather than by the data values.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.gnuplot, 400, 150 ; name=\"gnuplot\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.jet, 400, 150 ; name=\"jet\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.Hiroshige, 400, 150 ; name=\"Hiroshige\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.Hokusai1, 400, 150 ; name=\"Hokusai1\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.dracula, 400, 150 ; name=\"dracula\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.cubehelix, 400, 150 ; name=\"cubehelix\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/#References","page":"Good practice","title":"References","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"[Kovesi]: Good Colour Maps: How to Design Them | Peter Kovesi | arXiv:1509.03700 [cs.GR] | https://doi.org/10.48550/arXiv.1509.03700","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"[ZhouHansen]: A Survey of Colormaps in Visualization | Liang Zhou, Charles D Hansen | https://pubmed.ncbi.nlm.nih.gov/26513793/","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"DocTestSetup = quote\n using ColorSchemes, Colors\nend","category":"page"},{"location":"finding/#Finding-colors-in-colorschemes","page":"Finding colors","title":"Finding colors in colorschemes","text":"","category":"section"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"ColorSchemes.jl provides the function getinverse(cscheme, color) which is the inverse of get(cscheme, n). This function returns a number between 0 and 1 that best represents the location of a color on the colorscheme's 'axis'.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"(Image: \"get inverse\")","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"getinverse","category":"page"},{"location":"finding/#ColorSchemes.getinverse","page":"Finding colors","title":"ColorSchemes.getinverse","text":"getinverse(cscheme::ColorScheme, c, range=(0.0, 1.0))\n\nComputes where the provided Color c would fit in cscheme.\n\nThis is the inverse of get() — it returns the value x in the provided range for which get(scheme, x) would most closely match the provided Color c.\n\nExamples\n\nThe first example asks: \"where in the leonardo colorscheme will I find the nearest color to red?\":\n\njulia> getinverse(colorschemes[:leonardo], RGB(1, 0, 0))\n0.6248997995654847\n\njulia> getinverse(ColorScheme([Colors.RGB(0,0,0), Colors.RGB(1,1,1)]), Colors.RGB(.5,.5,.5))\n0.5432555858022048\n\njulia> cs = ColorScheme(range(Colors.RGB(0,0,0), stop=Colors.RGB(1,1,1), length=5))\n\njulia> getinverse(cs, cs[3])\n0.5\n\n\n\n\n\n","category":"function"},{"location":"finding/#Example-of-using-getinverse()","page":"Finding colors","title":"Example of using getinverse()","text":"","category":"section"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"One example use for getinverse() is to convert a heatmap image into an Array of continuous values, e.g. temperature.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"In this example, we will convert a heatmap image representing temperature into an array of elevation values. The image represents global temperature anomalies averaged from 2008 through 2012, with blue as -2°C and Red as +2°C. Higher than normal temperatures are shown in red (red is +2°C) and lower than normal temperatures are shown in blue (blue is -2°C). The global surface temperature in 2012 was +0.55°C. ","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"NASA archive source.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"using Images, FileIO, Downloads, ColorSchemes\nimg = Downloads.download(\"https://www.giss.nasa.gov/research/news/archive/20130115/719282main_2008_2012_printdata.1462.jpg\") |> load\nimg = imresize(img, Tuple(Int(x) for x in size(img) .* 0.2));\ndisplay(img)","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"(Image: \"heatmap 1\")","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"temps = [getinverse(ColorSchemes.temperaturemap, pixel) for pixel in img]\n\n432×768 Array{Float64,2}:\n 0.975615 0.975615 0.975615 0.975615 … 0.975615 0.975615 0.975615\n 0.975484 0.975767 0.975615 0.975615 0.975615 0.975615 0.975767\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 … 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n ⋮ ⋱ ⋮ \n 0.820419 0.820084 0.819388 0.819388 0.819977 0.821949 0.81973\n 0.816596 0.816055 0.816055 0.816055 … 0.819388 0.819388 0.818957\n 0.813865 0.813247 0.813247 0.813247 0.816055 0.815452 0.813865\n 0.810015 0.809307 0.809307 0.809307 0.813247 0.812582 0.812582\n 0.808566 0.805171 0.805171 0.805171 0.810015 0.810015 0.809307\n 0.804418 0.801045 0.80182 0.801045 0.805171 0.805171 0.805171\n 0.801045 0.802513 0.802513 0.800252 … 0.804418 0.804308 0.801045\n 0.802037 0.798624 0.798624 0.798624 0.802401 0.800252 0.802848","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"The image has been converted from its original colors to an array of continuous values between 0 and 1. This makes it possible to process as data. For example, we can find the places with the greatest anomalies:","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"mintemp, maxtemp = argmin(temps), argmax(temps)\n\n (CartesianIndex(397, 127), CartesianIndex(17, 314))","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"and these maximum and minimum 'coordinates' can be displayed on the image using another package that allows you to mix images, text, and vector graphics easily (such as Luxor.jl, for example).","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"save(\"/tmp/img.png\", img)\n\nusing Luxor\npngimg = readpng(\"/tmp/img.png\")\n\nw, h = pngimg.width, pngimg.height\n\nmaxpt = Point(maxtemp[2], maxtemp[1]) # image and graphics coords need swapping\nminpt = Point(mintemp[2], mintemp[1])\n\n@png begin\n placeimage(pngimg, O, centered=true)\n translate(-w/2, -h/2)\n sethue(\"mediumseagreen\")\n fontsize(20)\n fontface(\"Avenir-Black\")\n setopacity(0.75)\n circle(maxpt, 5, :fill)\n label(\"largest positive anomaly\", :E, maxpt, offset=20)\n circle(minpt, 5, :fill)\n label(\"largest negative anomaly\", :E, minpt, offset=20)\nend 800 460","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"(Image: \"heatmap min and max\")","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"We can display the array of continuous values as a grayscale image, where black is 0.0 and white is 1.0.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"Gray.(temps)","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"(Image: \"heatmap 2 grey\")","category":"page"},{"location":"images/","page":"Images","title":"Images","text":"DocTestSetup = quote\n using ColorSchemes, Colors\nend","category":"page"},{"location":"images/#Images","page":"Images","title":"Images","text":"","category":"section"},{"location":"images/#A-Julia-Julia-set:-ColorSchemes-and-Images","page":"Images","title":"A Julia Julia set: ColorSchemes and Images","text":"","category":"section"},{"location":"images/","page":"Images","title":"Images","text":"Here's an example of how you can use ColorSchemes when creating images with Images.jl. The code creates a Julia set and uses a pre-defined ColorScheme extracted from Vermeer's painting \"Girl with a Pearl Earring\" (shown at the right for reference).","category":"page"},{"location":"images/","page":"Images","title":"Images","text":"(Image: \"julia set\")","category":"page"},{"location":"images/","page":"Images","title":"Images","text":"using ColorSchemes, Images, FileIO\n# and possibly QuartzImageIO (macOS) and/or ImageMagick (Linux)\n\nfunction julia(z, c, maxiter::Int64)\n for n = 1:maxiter\n if abs(z) > 2\n return n\n end\n z = z^2 + c\n end\n return maxiter\nend\n\n# convert a value between oldmin/oldmax to equivalent value between newmin/newmax\nremap(value, oldmin, oldmax, newmin, newmax) = ((value - oldmin) / (oldmax - oldmin)) * (newmax - newmin) + newmin\n\nfunction draw(c, imsize;\n xmin = -1, ymin = -1, xmax = 1, ymax = 1,\n filename = \"/tmp/julia-set.png\")\n imOutput = zeros(RGB{Float32}, imsize, imsize)\n maxiterations = 200\n for col = range(xmin, stop=xmax, length=imsize)\n for row = range(ymin, stop=ymax, length=imsize)\n pixelcolor = julia(complex(row, col), c, maxiterations) / 256\n xpos = convert(Int, round(remap(col, xmin, xmax, 1, imsize)))\n ypos = convert(Int, round(remap(row, ymin, ymax, 1, imsize)))\n imOutput[xpos, ypos] = get(ColorSchemes.vermeer, pixelcolor)\n end\n end\n save(filename, imOutput)\nend\n\ndraw(-0.4 + 0.6im, 1200)","category":"page"},{"location":"basics/#Basics","page":"Basic usage","title":"Basics","text":"","category":"section"},{"location":"basics/#ColorScheme-objects","page":"Basic usage","title":"ColorScheme objects","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"When you start using ColorSchemes, it loads a set of pre-defined ColorSchemes in a dictionary called colorschemes.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"A ColorScheme is a Julia object which contains:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"an array of colors (eg RGB(0.1, 0.3, 0.4))\na string defining a category\na string that can contain descriptive notes","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"To access one of these built-in colorschemes, use its symbol:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes # hide\nColorSchemes.leonardo # or colorschemes[:leonardo]","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"The display depends on your working environment. If you’re using a notebook or IDE environment, the colors in the colorscheme should appear as a swatch in a cell or in a Plots window. Otherwise, you’ll see the colors listed as RGB values:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"32-element Array{RGB{Float64},1}:\n RGB{Float64}(0.0548203,0.016509,0.0193152)\n RGB{Float64}(0.0750816,0.0341102,0.0397083)\n RGB{Float64}(0.10885,0.0336675,0.0261204)\n RGB{Float64}(0.100251,0.0534243,0.0497594)\n ...\n RGB{Float64}(0.620187,0.522792,0.216707)\n RGB{Float64}(0.692905,0.56631,0.185515)\n RGB{Float64}(0.681411,0.58149,0.270391)\n RGB{Float64}(0.85004,0.540122,0.136212)\n RGB{Float64}(0.757552,0.633425,0.251451)\n RGB{Float64}(0.816472,0.697015,0.322421)\n RGB{Float64}(0.933027,0.665164,0.198652)\n RGB{Float64}(0.972441,0.790701,0.285136)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"You can access the array of colors as:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"ColorSchemes.leonardo.colors","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"By default, the colorscheme names aren’t imported. To avoid using the prefixes, you can import the ones that you want:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> import ColorSchemes.leonardo\njulia> leonardo\n32-element Array{RGB{Float64},1}:\n RGB{Float64}(0.0548203,0.016509,0.0193152)\n RGB{Float64}(0.0750816,0.0341102,0.0397083)\n RGB{Float64}(0.10885,0.0336675,0.0261204)\n RGB{Float64}(0.100251,0.0534243,0.0497594)\n ...\n RGB{Float64}(0.757552,0.633425,0.251451)\n RGB{Float64}(0.816472,0.697015,0.322421)\n RGB{Float64}(0.933027,0.665164,0.198652)\n RGB{Float64}(0.972441,0.790701,0.285136)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"You can reference a single value of a scheme:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"leonardo[3]\n\n-> RGB{Float64}(0.10884977211887092,0.033667530751245296,0.026120424375656533)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Or you can ‘sample’ the scheme at any point between 0 and 1 using get or getindex:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"get(leonardo, 0.5)\n\n-> RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)\n\nleonardo[0.5]\n\n-> RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"get","category":"page"},{"location":"basics/#Base.get","page":"Basic usage","title":"Base.get","text":"get(cscheme::ColorScheme, inData :: Array{Number, 2}, rangescale=:clamp)\nget(cscheme::ColorScheme, inData :: Array{Number, 2}, rangescale=(minVal, maxVal))\n\nReturn an RGB array of colors generated by applying the colorscheme to the 2D input data.\n\nIf rangescale is :clamp the colorscheme is applied to values between 0.0-1.0, and values outside this range get clamped to the ends of the colorscheme.\n\nIf rangescale is :extrema, the colorscheme is applied to the range minimum(indata)..maximum(indata).\n\nElse, if rangescale is :centered, the colorscheme is applied to the range -maximum(abs, indata)..maximum(abs, indata).\n\nTODO: this function expects the colorscheme to consist of RGB [0.0-1.0] values. It should work with more colortypes.\n\nExamples\n\nimg = get(colorschemes[:leonardo], rand(10,10)) # displays in Juno Plots window, but\nsave(\"testoutput.png\", img) # you'll need FileIO or similar to do this\n\nimg2 = get(colorschemes[:leonardo], 10.0 * rand(10, 10), :extrema)\nimg3 = get(colorschemes[:leonardo], 10.0 * rand(10, 10), (1.0, 9.0))\n\n# Also works with PerceptualColourMaps\nusing PerceptualColourMaps # warning, installs PyPlot, PyCall, LaTeXStrings\nimg4 = get(PerceptualColourMaps.cmap(\"R1\"), rand(10,10))\n\n\n\n\n\nget(cs::ColorScheme, g::Color{T,1} where T<:Union{Bool, AbstractFloat, FixedPoint})\n\nReturn the color in cs that corresponds to the gray value g.\n\n\n\n\n\n","category":"function"},{"location":"basics/#The-colorschemes-dictionary","page":"Basic usage","title":"The colorschemes dictionary","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"The ColorSchemes module automatically provides a number of predefined schemes. All the colorschemes are stored in an exported dictionary, called colorschemes.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"colorschemes[:summer] |> show\n ColorScheme(\n ColorTypes.RGB{Float64}[\n RGB{Float64}(0.0,0.5,0.4),\n RGB{Float64}(0.01,0.505,0.4),\n RGB{Float64}(0.02,0.51,0.4),\n RGB{Float64}(0.03,0.515,0.4),\n ...\n RGB{Float64}(1.0,1.0,0.4)],\n \"matplotlib\",\n \"sampled color schemes, sequential linearly-increasing shades of green-yellow\")","category":"page"},{"location":"basics/#Finding-colorschemes","page":"Basic usage","title":"Finding colorschemes","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Use the findcolorscheme function to search through the pre-defined colorschemes. The string you provide can occur in the colorscheme’s name, in the category, or (optionally) in the notes. It’s interpreted as a case-insensitive regular expression.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> findcolorscheme(\"ice\")\n\ncolorschemes containing \"ice\"\n\n seaborn_icefire_gradient\n seaborn_icefire_gradient (notes) sequential, ice fire gradient...\n ice \n flag_is (notes) The flag of Iceland...\n botticelli \n botticelli (notes) palette from artist Sandro Bot...\n\n\n ...found 6 results for \"ice\"","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"The function returns a list of matching colorscheme names as symbols.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"findcolorscheme","category":"page"},{"location":"basics/#ColorSchemes.findcolorscheme","page":"Basic usage","title":"ColorSchemes.findcolorscheme","text":"findcolorscheme(str;\n search_notes=true)\n\nFind all colorschemes matching str. str is interpreted as a regular expression (case-insensitive).\n\nThis returns an array of symbols which are the names of matching schemes in the colorschemes dictionary.\n\njulia> findcolorscheme(\"ice\")\n\ncolorschemes containing \"ice\"\n\n seaborn_icefire_gradient\n seaborn_icefire_gradient (notes) sequential, ice fire gradient...\n ice\n flag_is (notes) The flag of Iceland...\n botticelli\n botticelli (notes) palette from artist Sandro Bot...\n\n\n ...found 6 results for \"ice\"\n\nTo read the notes of a built-in colorscheme cscheme:\n\ncolorschemes[:cscheme].notes\n\n\n\n\n\n","category":"function"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"If you prefer, you can ‘roll your own’ search.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"[k for (k, v) in ColorSchemes.colorschemes if occursin(r\"colorbrew\"i, v.category)]\n265-element Array{Symbol,1}:\n :BuPu_6\n :Spectral_4\n :RdYlGn_5\n ⋮\n :BrBG_8\n :Oranges_4","category":"page"},{"location":"basics/#Make-your-own-colorscheme","page":"Basic usage","title":"Make your own colorscheme","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Using Colors.jl, you can quickly define a range of colors and use it to make a colorscheme:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes\ncs1 = ColorScheme(range(colorant\"red\", colorant\"green\", length=5))","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes\ncs1 = ColorScheme(reverse(Colors.sequential_palette(300, 100, logscale=true)))","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Or you can easily make your own by building an array:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes\nmygrays = ColorScheme([RGB{Float64}(i, i, i) for i in 0:0.1:1.0])","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Give it a category or some added notes if you want:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"mygrays = ColorScheme([RGB{Float64}(i, i, i) for i in 0:0.1:1.0],\n \"my useful schemes\", \"just some dull grey shades\")","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"although this scheme won’t end up in the colorschemes dictionary.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Another example, starting with a two-color scheme, then building a gradient from the first color to the other.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"myscheme = ColorScheme([Colors.RGB(1.0, 0.0, 0.0), Colors.RGB(0.0, 1.0, 0.0)],\n \"custom\", \"twotone, red and green\")\nColorScheme([get(myscheme, i) for i in 0.0:0.01:1.0])","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Another way is to use the loadcolorscheme function:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors\nloadcolorscheme(:mygrays, [RGB{Float64}(i, i, i) for i in 0:0.1:1.0],\n \"useful schemes\", \"just some dull grey shades\")","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"and that will be added (temporarily) to the built-in list.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> findcolorscheme(\"dull\")\n\ncolorschemes containing \"dull\"\n\n mygrays (notes) just some dull grey shades...\n\n\n ...found 1 result for \"dull\"","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"If you want to make more advanced ColorSchemes, use linear-segment dictionaries or indexed lists, and use functions to generate color values, see the make_colorscheme() function in the ColorSchemeTools.jl package.","category":"page"},{"location":"basics/#For-CVD-(color-vision-deficient-or-\"color-blind\")-users","page":"Basic usage","title":"For CVD (color-vision deficient or \"color-blind\") users","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"This package contains a number of colorschemes that are designed to be helpful for people with some deficiencies in their perception of color:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"deuteranomaly (where green looks more red)\nprotanomaly (where red looks more green and less bright)\ntritanomaly (difficult to tell the difference between blue and green, and between yellow and red)\ntritanopia (difficult to tell the difference between blue and green, purple and red, and yellow and pink)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"findcolorscheme(\"cvd\")\n\ncolorschemes containing \"cvd\"\n\n tol_light (category) cvd\n tol_muted (category) cvd\n tol_bright (category) cvd\n okabe_ito (category) cvd\n mk_8 (category) cvd\n mk_12 (category) cvd\n mk_15 (category) cvd","category":"page"},{"location":"basics/#:tol_light","page":"Basic usage","title":":tol_light","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.tol_light # hide","category":"page"},{"location":"basics/#:tol_muted","page":"Basic usage","title":":tol_muted","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.tol_muted # hide","category":"page"},{"location":"basics/#:tol_bright","page":"Basic usage","title":":tol_bright","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.tol_bright # hide","category":"page"},{"location":"basics/#:okabe_ito","page":"Basic usage","title":":okabe_ito","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.okabe_ito # hide","category":"page"},{"location":"basics/#:mk_8","page":"Basic usage","title":":mk_8","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.mk_8 # hide","category":"page"},{"location":"basics/#:mk_12","page":"Basic usage","title":":mk_12","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.mk_12 # hide","category":"page"},{"location":"basics/#:mk_15","page":"Basic usage","title":":mk_15","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.mk_15 # hide","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Also, it's possible to generate schemes using Colors.distinguishable_colors():","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes\nColorScheme(distinguishable_colors(10, transform=protanopic))","category":"page"},{"location":"basics/#Continuous-color-sampling","page":"Basic usage","title":"Continuous color sampling","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"You can access the specific colors of a colorscheme by indexing (eg leonardo[2] or leonardo[5:end]). Or you can sample a ColorScheme at a point between 0.0 and 1.0 as if it were a continuous range of colors:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"get(leonardo, 0.5)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"returns","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"(Image: \"get example\")","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"The colors in the predefined ColorSchemes are usually sorted by LUV luminance, so this often makes sense.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"You can use get() with index data in arrays to return arrays of colors:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> get(leonardo, [0.0, 0.5, 1.0])\n3-element Array{RGB{Float64},1} with eltype ColorTypes.RGB{Float64}:\n RGB{Float64}(0.05482025926320272,0.016508952654741622,0.019315160361063788)\n RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132) \n RGB{Float64}(0.9724409077178674,0.7907008712807734,0.2851364857083522)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"(Image: \"get example 2\")","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> simg = get(leonardo, rand(10, 16));\njulia> using FileIO\njulia> save(\"mosaic.png\", simg)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"(Image: \"get example 1\")","category":"page"},{"location":"basics/#Matplotlib-compatibility","page":"Basic usage","title":"Matplotlib compatibility","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Most of the color schemes in Matplotlib are available. The following code example gives a general picture.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes\n\n# https://matplotlib.org/examples/color/colormaps_reference.html\n\nmatplotlibcmaps = Dict(\n :perceptuallyuniformsequential => [\n :viridis, :plasma, :inferno, :magma],\n :sequential => [\n :Greys_9, :Purples_9, :Blues_9, :Greens_9, :Oranges_9, :Reds_9,\n :YlOrBr_9, :YlOrRd_9, :OrRd_9, :PuRd_9, :RdPu_9, :BuPu_9,\n :GnBu_9, :PuBu_9, :YlGnBu_9, :PuBuGn_9, :BuGn_9, :YlGn_9],\n :sequential2 => [\n :binary, :gist_yarg, :gist_gray, :gray, :bone, :pink,\n :spring, :summer, :autumn, :winter, :cool, :Wistia,\n :hot, :afmhot, :gist_heat, :copper],\n :diverging => [\n :PiYG_11, :PRGn_11, :BrBG_11, :PuOr_11, :RdGy_11, :RdBu_11,\n :RdYlBu_11, :RdYlGn_11, :Spectral_11, :coolwarm, :bwr, :seismic],\n :cyclical => [\n :twilight, :twilight_shifted, :hsv],\n :qualitative => [\n :Pastel1_9, :Pastel2_8, :Paired_11, :Accent_8,\n :Dark2_8, :Set1_9, :Set2_8, :Set3_12,\n :tab10, :tab20, :tab20b, :tab20c],\n :miscellaneous => [\n :flag, :prism, :ocean, :gist_earth, :terrain, :gist_stern,\n :gnuplot, :gnuplot2, :CMRmap, :cubehelix, :brg, :hsv,\n :gist_rainbow, :rainbow, :jet, :nipy_spectral, :gist_ncar]\n )\n\nfor (k, v) in matplotlibcmaps\n println(\"$(rpad(k, 12)) $(length(v))\")\n for cs in v\n try\n c = ColorSchemes.colorschemes[cs]\n catch\n println(\"\\t$(rpad(cs, 12)) not currently in stock\")\n end\n end\nend","category":"page"},{"location":"basics/#Alpha-transparency","page":"Basic usage","title":"Alpha transparency","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"To convert a colorscheme to one with transparency, you could use a function like this:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"function colorscheme_alpha(cscheme::ColorScheme, alpha::T = 0.5; \n ncolors=12) where T<:Real\n return ColorScheme([RGBA(get(cscheme, k), alpha) for k in range(0, 1, length=ncolors)])\nend\n\ncolors = colorscheme_alpha(ColorSchemes.ice, ncolors=12)","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"# this code will display all the schemes in a category, as an SVG\n# use in this docs/src/catalogue.md file as\n# ```@example catalog\n# using Luxor, ColorSchemes # hide\n# ColorSchemeCategory(\"cmocean\") # hide\n# ```\n# which displays the \"cmocean\" category\n\nusing Luxor, ColorSchemes\n\nstruct ColorSchemeGroup\n name::String\nend\n\nfunction generate_scheme_svg(schemename;\n swatchwidth = 800,\n swatchheight = 20)\n # create swatch\n cols = colorschemes[schemename].colors\n l = length(cols)\n Drawing(swatchwidth, swatchheight, :svg)\n setline(0.5)\n origin()\n t = Tiler(swatchwidth, swatchheight, 1, l, margin=0)\n for (i, c) in enumerate(cols)\n sethue(c)\n box(t, i, :fillstroke)\n end\n finish()\n\n swatch = svgstring()\n\n # fill the template\n schemetemplate = \"\"\"\n \n
:$(schemename)
\n
\n
$(swatch)
\n \"\"\"\n return schemetemplate\nend\n\nfunction generate_schemes_in_category(category)\n iobuffer = IOBuffer()\n\n write(iobuffer, \"\"\"\n
\n \"\"\")\n\n schemes = filter(s -> occursin(category, colorschemes[s].category), collect(keys(colorschemes)))\n for s in sort(schemes, lt = (s1, s2) -> lowercase(string(s1)) < lowercase(string(s2)))\n write(iobuffer, generate_scheme_svg(s))\n end\n write(iobuffer, \"\"\"\n
\n \"\"\")\n\n return String(take!(iobuffer))\nend\n\nfunction generate_schemes_matching_notes_string(str)\n iobuffer = IOBuffer()\n\n write(iobuffer, \"\"\"\n
\n \"\"\")\n\n schemes = filter(s -> occursin(str, colorschemes[s].notes), collect(keys(colorschemes)))\n for s in sort(schemes, lt = (s1, s2) -> lowercase(string(s1)) < lowercase(string(s2)))\n write(iobuffer, generate_scheme_svg(s))\n end\n write(iobuffer, \"\"\"\n
\n \"\"\")\n\n return String(take!(iobuffer))\nend\n\nfunction Base.show(io::IO, m::MIME\"text/html\", category::ColorSchemeCategory)\n print(io, generate_schemes_in_category(category.name))\nend\n\nfunction Base.show(io::IO, m::MIME\"text/html\", group::ColorSchemeGroup)\n print(io, generate_schemes_matching_notes_string(group.name))\nend","category":"page"},{"location":"catalogue/#Catalogue-of-ColorSchemes","page":"Catalogue","title":"Catalogue of ColorSchemes","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"At the REPL you can search for colorschemes by name:","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"findcolorscheme(\"julia\")","category":"page"},{"location":"catalogue/#cmocean","page":"Catalogue","title":"✦ cmocean","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From \"Beautiful colormaps for oceanography\": cmocean","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"cmocean\") # hide","category":"page"},{"location":"catalogue/#scientific","page":"Catalogue","title":"✦ scientific","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From Scientific colormaps","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"scientific\") # hide","category":"page"},{"location":"catalogue/#matplotlib","page":"Catalogue","title":"✦ matplotlib","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From matplot","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"matplotlib\") # hide","category":"page"},{"location":"catalogue/#colorbrewer","page":"Catalogue","title":"✦ colorbrewer","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From ColorBrewer","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"colorbrewer\") # hide","category":"page"},{"location":"catalogue/#gnuplot","page":"Catalogue","title":"✦ gnuplot","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From GNUPlot","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"gnuplot\") # hide","category":"page"},{"location":"catalogue/#colorcet","page":"Catalogue","title":"✦ colorcet","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From \"collection of perceptually accurate colormaps\"","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"colorcet\") # hide","category":"page"},{"location":"catalogue/#Seaborn","page":"Catalogue","title":"✦ Seaborn","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From \"colorschemes used by Seaborn, a Python data visualization library based on matplotlib.\"","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"seaborn\") # hide","category":"page"},{"location":"catalogue/#ggthemes/tableau","page":"Catalogue","title":"✦ ggthemes/tableau","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From \"ggthemes tableau palettes\"","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"tableau\") # hide","category":"page"},{"location":"catalogue/#Color-Vision-Deficient-friendly-schemes","page":"Catalogue","title":"✦ Color-Vision Deficient-friendly schemes","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Colorschemes designed with color-vision deficient users in mind, by authors such as Paul Tol, Masataka Okabe, Kei Ito, and Martin Krzywinski. This list also includes schemes with \"cvd\" in the Notes field.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"cvd\") # hide\nColorSchemeGroup(\"cvd\") # hide","category":"page"},{"location":"catalogue/#Flags","page":"Catalogue","title":"✦ Flags","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Colors extracted from flags of different countries and regions, downloaded from Flagpedia. Intended to represent these regions in visualizations, but not necessarily effective. Many flags have similar colorschemes. The flags are named according to the region's ISO3166 two-letter abbreviation (often the same as top-level WWW domain), with any hyphens removed.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"flags\") # hide","category":"page"},{"location":"catalogue/#MetBrewer","page":"Catalogue","title":"✦ MetBrewer","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Palettes inspired by works at the Metropolitan Museum of Art in New York. See Blake Mills' github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"MetBrewer\") # hide","category":"page"},{"location":"catalogue/#Pacific-North-West","page":"Catalogue","title":"✦ Pacific North West","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"The colors of Washington State and the Pacific Northwest of the USA. See Jake Lawlor's github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"PNW Pacific North West\") # hide","category":"page"},{"location":"catalogue/#Wes-Anderson","page":"Catalogue","title":"✦ Wes Anderson","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Palettes derived from the films of Wes Anderson. See Karthik's github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"Wes Anderson\") # hide","category":"page"},{"location":"catalogue/#Ghibli","page":"Catalogue","title":"✦ Ghibli","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Palettes derived from the films of Studio Ghibli. See Ewenme's github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"Ghibli\") # hide","category":"page"},{"location":"catalogue/#Feathers","page":"Catalogue","title":"+ Feathers","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Palattes derived from the plumage of Australian birds. See Shandiya's github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"Feathers\") # hide","category":"page"},{"location":"catalogue/#general-and-miscellaneous","page":"Catalogue","title":"✦ general and miscellaneous","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"general\") # hide","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"nord\") # hide","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"kindlmann\") # hide","category":"page"},{"location":"catalogue/#Julia-logo-colorschemes","page":"Catalogue","title":"✦ Julia logo colorschemes","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"julia\") # hide","category":"page"},{"location":"catalogue/#Pride-colorschemes","page":"Catalogue","title":"✦ Pride colorschemes","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"pride\") # hide","category":"page"},{"location":"plotting/#Plotting","page":"Plotting","title":"Plotting","text":"","category":"section"},{"location":"plotting/#UnicodePlots.jl","page":"Plotting","title":"UnicodePlots.jl","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"The heatmap() function in UnicodePlots.jl can use colorschemes. You have to supply the colors as an array of floating-point numbers first:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"... colormap = [(x.r, x.g, x.b) for x in ColorSchemes.leonardo.colors]","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"For example:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"heatmap(z::AbstractMatrix; title = \"Hot!\",\n colormap = [(x.r, x.g, x.b) for x in ColorSchemes.leonardo.colors])","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"heatmap\")","category":"page"},{"location":"plotting/#Plots.jl","page":"Plotting","title":"Plots.jl","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"Plots.jl supports all colorschemes from ColorSchemes.jl. They can be used as a gradient or as a palette and are passed as a symbol holding their name to cgrad or palette.","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"This renaissance-looking plot uses the leonardo scheme:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Plots\n\nx = 1:0.3:20\ny = x\nf(x, y) = begin\n sin(x) + cos(y)\n end\ncontour(x, y, f, fill=true, c = :leonardo)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"contour\")","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(You can use c as a short cut for seriescolor.)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"With other plots, use the palette keyword:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using ColorSchemes\n\nplot(Plots.fakedata(100, 20),\n w=4,\n background_color=ColorSchemes.vermeer[1],\n palette=:vermeer)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"palette\")","category":"page"},{"location":"plotting/#Gadfly","page":"Plotting","title":"Gadfly","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"Here's how you can use ColorSchemes in Gadfly:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Gadfly, ColorSchemes\nx = repeat(collect(1:20), inner=[20]);\ny = repeat(collect(1:20), outer=[20]);\nplot(x=x, y=y,\n color=x+y,\n Geom.rectbin,\n Scale.ContinuousColorScale(p -> get(ColorSchemes.sunset, p)))","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"gadfly\")","category":"page"},{"location":"plotting/#Makie","page":"Plotting","title":"Makie","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"If you use Makie.jl you can pass the colors in a ColorScheme directly to the colormap keyword.","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Makie, ColorSchemes\nN = 20\nx = LinRange(-0.3, 1, N)\ny = LinRange(-1, 0.5, N)\nz = x .* y'\nimage(x, y, z, colormap = ColorSchemes.picasso.colors)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"makie\")","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"You can display all the colorschemes using Makie by letting the code browse through the colorschemes dictionary:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Makie, ColorSchemes\n\nh = 0.0\noffset = 0.1\nscene = Scene()\ncam2d!(scene)\nplot = map(collect(keys(colorschemes))) do cmap\n global h\n c = to_colormap(colorschemes[cmap].colors)\n cbar = image!(\n scene,\n range(0, stop = 10, length = length(c)),\n range(0, stop = 1, length = length(c)),\n reshape(c, (length(c), 1)),\n show_axis = false\n )[end]\n text!(\n scene,\n string(cmap, \":\"),\n position = Point2f0(-0.1, 0.5 + h),\n align = (:right, :center),\n show_axis = false,\n textsize = 0.4\n )\n translate!(cbar, 0, h, 0)\n h -= (1 + offset)\nend\nscene","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"makie all colorschemes\")","category":"page"},{"location":"plotting/#Winston","page":"Plotting","title":"Winston","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"If you prefer Winston.jl for plotting, you can use ColorSchemes with imagesc:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Winston, ColorSchemes\nklimt = ColorSchemes.klimt.colors\nWinston.colormap(klimt)\nWinston.imagesc(reshape(1:10000,100,100))","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"winston klimt\")","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"Sometimes you'll want a smoother gradient with more colors. You can use get(scheme, n) to generate a more detailed array of colors, varying n from 0 to 1 by 0.001:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"brasstones = ColorSchemes.brass\nbrasstonesmooth = [get(brasstones, i) for i in 0:0.001:1]\nWinston.colormap(brasstonesmooth)\nWinston.imagesc(reshape(1:10000,100,100))","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"winston brass tones)","category":"page"},{"location":"plotting/#PyPlot","page":"Plotting","title":"PyPlot","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"ColorSchemes can be used with the cmap keyword in PyPlot:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using PyPlot, Distributions, ColorSchemes\n\nsolar = ColorSchemes.solar.colors\n\nn = 100\nx = range(-3, stop=3, length=n)\ny = range(-3, stop=3, length=n)\n\nxgrid = repeat(x', n, 1);\nygrid = repeat(y, 1, n);\nz = zeros(n, n);\n\nfor i in 1:n\n for j in 1:n\n z[i, j] = 2sin(x[i]) * 2cos(y[j])\n end\nend\n\nfig = PyPlot.figure(\"pyplot_surfaceplot\",figsize=(10,10))\n\nusing3D()\nax = fig.add_subplot(2, 1, 1, projection = \"3d\")\n\nax.plot_surface(xgrid, ygrid, z, rstride=2,edgecolors=\"k\",\n cstride=2,\n cmap=ColorMap(solar),\n alpha=0.8,\n linewidth=0.25)\n\ndisplay(fig)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"pyplot\")","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"DocTestSetup = quote\n using ColorSchemes, Colors\nend","category":"page"},{"location":"#Introduction-to-ColorSchemes","page":"Introduction","title":"Introduction to ColorSchemes","text":"","category":"section"},{"location":"","page":"Introduction","title":"Introduction","text":"This package provides a collection of colorschemes:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"scientifically devised colorschemes from ColorBrewer, CMOcean, ScientificColorMaps, ColorCet, and Seaborn\npopular favourites such as viridis, inferno, and magma from MATPlotLib\nvariously themed colorschemes such as sunset, coffee, neon, and pearl\nartistic colorschemes, such as leonardo, vermeer, picasso, Degas, Hiroshige, ","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"Note that the schemes contained here are a mixture:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"some are high quality color maps with consistent perceptual contrast over their full range\nothers are designed for general purpose and informal graphics work","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"Choose colorschemes with care! See the Good practice section, and also refer to Peter Kovesi's PerceptualColourMaps package, or to Fabio Crameri's Scientific Colour Maps for technical information.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"This package relies on the Colors.jl package.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"If you want to make more advanced ColorSchemes, use linear-segment dictionaries or indexed lists, and use functions to generate color values, see the make_colorscheme() function in the ColorSchemeTools.jl package.","category":"page"},{"location":"#Installation-and-basic-usage","page":"Introduction","title":"Installation and basic usage","text":"","category":"section"},{"location":"","page":"Introduction","title":"Introduction","text":"Install the package as follows:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"import Pkg\nPkg.add(\"ColorSchemes\")","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"or, at the REPL:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"] add ColorSchemes","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"Usage:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"using ColorSchemes\n\nColorSchemes.Purples_5 \n# => a ColorScheme \n\ncolorschemes[:Purples_5]\n# => a ColorScheme \n\nColorSchemes.Purples_5.colors\n# => array of five RGB colors\n\nColorSchemes.Purples_5.colors[3]\n# => the third color in the colorscheme\n\nget(ColorSchemes.Purples_5, 0.5)\n# => the midway point of the colorscheme \n\ncolorschemes\n# => Dict{Symbol, ColorScheme} with 1150 entries\n\nfindcolorscheme(\"purple\")\n# => display list of matching schemes","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"Original version by cormullion.","category":"page"},{"location":"#Contributing-a-new-colorscheme","page":"Introduction","title":"Contributing a new colorscheme","text":"","category":"section"},{"location":"","page":"Introduction","title":"Introduction","text":"If you think a new colorscheme would be a great addition for you and for Julians everywhere, you can contribute it as follows:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"1 Add a file to the data/ directory. The file should be a Julia file, with a .jl suffix.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"2 Inside the file, define a colorscheme in this format, which calls loadcolorscheme:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"loadcolorscheme(:mynewcolorscheme, [\n RGB(0.0, 0.0, 0.0),\n RGB(0.5, 0.5, 0.5),\n RGB(1.0, 1.0, 1.0),\n ], \n \"category for my new scheme\", # the category\n \"black, white, and grey\" # some descriptive keywords\n )","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"The new name - here mynewcolorscheme - should be a valid Julia variable name.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"3 If you're adding the new colorscheme to an existing category, it will appear in the catalog document automatically.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"4 Otherwise, to add a new category to the catalog (which will add all the colorschemes in that category), add this code to catalogue.md:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":" ```@example catalog\n using Luxor, ColorSchemes # hide\n ColorSchemeCategory(\"category for my new scheme\") # hide\n ```","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"5 If there's a license file, add it to data/ as well.","category":"page"},{"location":"#Documentation","page":"Introduction","title":"Documentation","text":"","category":"section"},{"location":"","page":"Introduction","title":"Introduction","text":"This documentation was built using Documenter.jl.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"using Dates # hide\nprintln(\"Documentation built $(Dates.now()) with Julia $(VERSION)\") # hide","category":"page"}] +[{"location":"functionindex/#Function-index","page":"Functions","title":"Function index","text":"","category":"section"},{"location":"functionindex/","page":"Functions","title":"Functions","text":"","category":"page"},{"location":"references/#References","page":"References","title":"References","text":"","category":"section"},{"location":"references/#cmocean","page":"References","title":"✦ cmocean","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From \"Beautiful colormaps for oceanography\": cmocean","category":"page"},{"location":"references/#scientific","page":"References","title":"✦ scientific","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From Scientific colormaps","category":"page"},{"location":"references/#matplotlib","page":"References","title":"✦ matplotlib","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From matplot","category":"page"},{"location":"references/#colorbrewer","page":"References","title":"✦ colorbrewer","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From ColorBrewer","category":"page"},{"location":"references/#gnuplot","page":"References","title":"✦ gnuplot","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From GNUPlot","category":"page"},{"location":"references/#colorcet","page":"References","title":"✦ colorcet","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From \"collection of perceptually accurate colormaps\"","category":"page"},{"location":"references/#Seaborn","page":"References","title":"✦ Seaborn","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From \"colorschemes used by Seaborn, a Python data visualization library based on matplotlib.\"","category":"page"},{"location":"references/#ggthemes/tableau","page":"References","title":"✦ ggthemes/tableau","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"From \"ggthemes tableau palettes\"","category":"page"},{"location":"references/#CVD/(ColorBlind)-friendly-schemes","page":"References","title":"✦ CVD/(ColorBlind)-friendly schemes","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"Colorschemes designed with color-vision deficient users in mind, by authors such as Paul Tol, Masataka Okabe, Kei Ito, and Martin Krzywinski.","category":"page"},{"location":"references/#Flags","page":"References","title":"✦ Flags","text":"","category":"section"},{"location":"references/","page":"References","title":"References","text":"Colors extracted from flags of different countries and regions, downloaded from Flagpedia. Intended to represent these regions in visualizations, but not necessarily effective. Many flags have similar colorschemes. The flags are named according to the region's ISO3166 two-letter abbreviation (often the same as top-level WWW domain), with any hyphens removed.","category":"page"},{"location":"references/#general-and-miscellaneous","page":"References","title":"✦ general and miscellaneous","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors\n\nfunction draw_lightness_swatch(cs::ColorScheme, width = 800, height=150;\n\t\tname=\"\")\n\t@drawsvg begin\n\t\thmargin= 30\n\t\tvmargin= 20\n\t\tbb = BoundingBox(Point(-width/2 + hmargin, -height/2 + vmargin), Point(width/2 - hmargin, height/2 - vmargin))\n\n\t\tbackground(\"black\")\n\t\tfontsize(8)\n\t\tsethue(\"white\")\n\t\tsetline(0.5)\n\t\tbox(bb, :stroke)\n\n\t\ttickline(boxbottomleft(bb), boxbottomright(bb), major = 9, axis=false,\n\t\t\tmajor_tick_function = (n, pos; startnumber, finishnumber, nticks) ->\n\t\t\t\ttext(string(n/10), pos + (0, 12), halign=:center)\n\t\t\t)\n\n\t\ttickline(boxbottomright(bb), boxtopright(bb), major = 9, axis=false,\n\t\t\tmajor_tick_function = (n, pos; startnumber, finishnumber, nticks) ->\n\t\t\t\ttext(string(10n), pos + (0, 20), angle=π/2, halign=:right, valign=:middle)\n\t\t\t)\n\n\t\ttext(\"lightness\", boxtopleft(bb) + (10, 10), halign=:right, angle=-π/2)\n\n\t\tfontsize(12)\n\t\tL = 70\n\t\tsw = width/L\n\t\tsaved = Point[]\n\t\tfor i in range(0.0, 1.0, length=L)\n\t\t\tpos = between(boxmiddleleft(bb), boxmiddleright(bb), i)\n\t\t\tcolor = get(cs, i)\n\t\t\tsetcolor(color)\n\t\t\tlabcolor = convert(Lab, color)\n\t\t\tlightness = labcolor.l\n\t\t\tlightnesspos = pos + (0, boxheight(bb)/2 - rescale(labcolor.l, 0, 100, 0, boxheight(bb)))\n\t\t\tpush!(saved, lightnesspos)\n\t\t\tcircle(lightnesspos, 5, :fill)\n\n\t\tend\n\n#\t\tsetline(1)\n#\t\tsethue(\"black\")\n#\t\tline(saved[1], saved[end], :stroke)\n#\t\tsetline(0.8)\n#\t\tline(saved[1], saved[end], :stroke)\n\n sethue(\"white\")\n\t\ttext(name, boxtopcenter(bb) + (0, -6), halign=:center)\n\tend width height\nend","category":"page"},{"location":"goodpractice/#Good-practice","page":"Good practice","title":"Good practice","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"There are hundreds of colorschemes in this package, and they're useful for many different purposes. However, if you're intending to use a colorscheme for communicating features of a scientific dataset, you should choose it with care.","category":"page"},{"location":"goodpractice/#Perceptual-uniformity","page":"Good practice","title":"Perceptual uniformity","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"You should choose a perceptually uniform colorscheme: a set of colors arranged so that equal steps in data are perceived by the viewer as equal steps in the color space.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"Researchers[Kovesi][ZhouHansen] have found that the human brain perceives changes in the lightness parameter as changes in the data much better than, for example, changes in hue. So sequential colorschemes with monotonically increasing lightness values will be better interpreted by the viewer.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"The Lab color space represents a color with three components: Lightness, RedGreen, and YellowBlue. The Lightness parameter can be used to indicate how uniform the colors will be perceived by viewers.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"In the following diagrams, the Lightness Lab component of each color step is plotted in y as x moves through the colorscheme. You can see how the lightness increases evenly in the recommended schemes.","category":"page"},{"location":"goodpractice/#Recommended","page":"Good practice","title":"Recommended","text":"","category":"section"},{"location":"goodpractice/#Sequential","page":"Good practice","title":"Sequential","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"Good choices include viridis, inferno, plasma, magma:","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.viridis, 400, 150 ; name=\"viridis\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.inferno, 400, 150 ; name=\"inferno\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.plasma, 400, 150 ; name=\"plasma\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.magma, 400, 150 ; name=\"magma\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"ColorCET schemes (findcolorscheme(\"colorcet\") will return the very long names to save you typing them):","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.linear_kbc_5_95_c73_n256, 400, 150 ; name=\"linear_kbc_5_95_c73_n256\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.linear_tritanopic_krjcw_5_95_c24_n256, 400, 150 ; name=\"linear_tritanopic_krjcw_5_95_c24_n256\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"Fabio Crameri's Scientific colorschemes:","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.tokyo, 400, 150 ; name=\"tokyo\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.devon, 400, 150 ; name=\"devon\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.hawaii, 400, 150 ; name=\"hawaii\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.buda, 400, 150 ; name=\"buda\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/#Diverging","page":"Good practice","title":"Diverging","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"For diverging colorschemes, the lightness values of the extremes should be broadly equivalent. As well as the diverging- ColorCET colorschemes, there are suitable schemes in Scientific, ColorBrewer, and others.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.RdBu, 400, 150 ; name=\"RdBu\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.BrBg, 400, 150 ; name=\"BrBg\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.RdBu, 400, 150 ; name=\"RdBu\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.BrBg, 400, 150 ; name=\"BrBg\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.diverging_bwr_55_98_c37_n256, 400, 150 ; name=\"diverging_bwr_55_98_c37_n256\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.diverging_rainbow_bgymr_45_85_c67_n256, 400, 150 ; name=\"diverging_rainbow_bgymr_45_85_c67_n256\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/#Less-suitable-for-data-visualization","page":"Good practice","title":"Less suitable for data visualization","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"Colorschemes with rapid changes in lightness are less suitable, because the viewer's interpretation of a region of data might be influenced by the coloring, rather than by the data values.","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.gnuplot, 400, 150 ; name=\"gnuplot\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.jet, 400, 150 ; name=\"jet\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.Hiroshige, 400, 150 ; name=\"Hiroshige\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.Hokusai1, 400, 150 ; name=\"Hokusai1\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"using Luxor, ColorSchemes, Colors # hide\nd1 = draw_lightness_swatch(ColorSchemes.dracula, 400, 150 ; name=\"dracula\") # hide\nd2 = draw_lightness_swatch(ColorSchemes.cubehelix, 400, 150 ; name=\"cubehelix\") # hide\nhcat(d1, d2) # hide","category":"page"},{"location":"goodpractice/#References","page":"Good practice","title":"References","text":"","category":"section"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"[Kovesi]: Good Colour Maps: How to Design Them | Peter Kovesi | arXiv:1509.03700 [cs.GR] | https://doi.org/10.48550/arXiv.1509.03700","category":"page"},{"location":"goodpractice/","page":"Good practice","title":"Good practice","text":"[ZhouHansen]: A Survey of Colormaps in Visualization | Liang Zhou, Charles D Hansen | https://pubmed.ncbi.nlm.nih.gov/26513793/","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"DocTestSetup = quote\n using ColorSchemes, Colors\nend","category":"page"},{"location":"finding/#Finding-colors-in-colorschemes","page":"Finding colors","title":"Finding colors in colorschemes","text":"","category":"section"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"ColorSchemes.jl provides the function getinverse(cscheme, color) which is the inverse of get(cscheme, n). This function returns a number between 0 and 1 that best represents the location of a color on the colorscheme's 'axis'.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"(Image: \"get inverse\")","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"getinverse","category":"page"},{"location":"finding/#ColorSchemes.getinverse","page":"Finding colors","title":"ColorSchemes.getinverse","text":"getinverse(cscheme::ColorScheme, c, range=(0.0, 1.0))\n\nComputes where the provided Color c would fit in cscheme.\n\nThis is the inverse of get() — it returns the value x in the provided range for which get(scheme, x) would most closely match the provided Color c.\n\nExamples\n\nThe first example asks: \"where in the leonardo colorscheme will I find the nearest color to red?\":\n\njulia> getinverse(colorschemes[:leonardo], RGB(1, 0, 0))\n0.6248997995654847\n\njulia> getinverse(ColorScheme([Colors.RGB(0,0,0), Colors.RGB(1,1,1)]), Colors.RGB(.5,.5,.5))\n0.5432555858022048\n\njulia> cs = ColorScheme(range(Colors.RGB(0,0,0), stop=Colors.RGB(1,1,1), length=5))\n\njulia> getinverse(cs, cs[3])\n0.5\n\n\n\n\n\n","category":"function"},{"location":"finding/#Example-of-using-getinverse()","page":"Finding colors","title":"Example of using getinverse()","text":"","category":"section"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"One example use for getinverse() is to convert a heatmap image into an Array of continuous values, e.g. temperature.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"In this example, we will convert a heatmap image representing temperature into an array of elevation values. The image represents global temperature anomalies averaged from 2008 through 2012, with blue as -2°C and Red as +2°C. Higher than normal temperatures are shown in red (red is +2°C) and lower than normal temperatures are shown in blue (blue is -2°C). The global surface temperature in 2012 was +0.55°C. ","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"NASA archive source.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"using Images, FileIO, Downloads, ColorSchemes\nimg = Downloads.download(\"https://www.giss.nasa.gov/research/news/archive/20130115/719282main_2008_2012_printdata.1462.jpg\") |> load\nimg = imresize(img, Tuple(Int(x) for x in size(img) .* 0.2));\ndisplay(img)","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"(Image: \"heatmap 1\")","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"temps = [getinverse(ColorSchemes.temperaturemap, pixel) for pixel in img]\n\n432×768 Array{Float64,2}:\n 0.975615 0.975615 0.975615 0.975615 … 0.975615 0.975615 0.975615\n 0.975484 0.975767 0.975615 0.975615 0.975615 0.975615 0.975767\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 … 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615 0.975615\n ⋮ ⋱ ⋮ \n 0.820419 0.820084 0.819388 0.819388 0.819977 0.821949 0.81973\n 0.816596 0.816055 0.816055 0.816055 … 0.819388 0.819388 0.818957\n 0.813865 0.813247 0.813247 0.813247 0.816055 0.815452 0.813865\n 0.810015 0.809307 0.809307 0.809307 0.813247 0.812582 0.812582\n 0.808566 0.805171 0.805171 0.805171 0.810015 0.810015 0.809307\n 0.804418 0.801045 0.80182 0.801045 0.805171 0.805171 0.805171\n 0.801045 0.802513 0.802513 0.800252 … 0.804418 0.804308 0.801045\n 0.802037 0.798624 0.798624 0.798624 0.802401 0.800252 0.802848","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"The image has been converted from its original colors to an array of continuous values between 0 and 1. This makes it possible to process as data. For example, we can find the places with the greatest anomalies:","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"mintemp, maxtemp = argmin(temps), argmax(temps)\n\n (CartesianIndex(397, 127), CartesianIndex(17, 314))","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"and these maximum and minimum 'coordinates' can be displayed on the image using another package that allows you to mix images, text, and vector graphics easily (such as Luxor.jl, for example).","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"save(\"/tmp/img.png\", img)\n\nusing Luxor\npngimg = readpng(\"/tmp/img.png\")\n\nw, h = pngimg.width, pngimg.height\n\nmaxpt = Point(maxtemp[2], maxtemp[1]) # image and graphics coords need swapping\nminpt = Point(mintemp[2], mintemp[1])\n\n@png begin\n placeimage(pngimg, O, centered=true)\n translate(-w/2, -h/2)\n sethue(\"mediumseagreen\")\n fontsize(20)\n fontface(\"Avenir-Black\")\n setopacity(0.75)\n circle(maxpt, 5, :fill)\n label(\"largest positive anomaly\", :E, maxpt, offset=20)\n circle(minpt, 5, :fill)\n label(\"largest negative anomaly\", :E, minpt, offset=20)\nend 800 460","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"(Image: \"heatmap min and max\")","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"We can display the array of continuous values as a grayscale image, where black is 0.0 and white is 1.0.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"Gray.(temps)","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"(Image: \"heatmap 2 grey\")","category":"page"},{"location":"images/","page":"Images","title":"Images","text":"DocTestSetup = quote\n using ColorSchemes, Colors\nend","category":"page"},{"location":"images/#Images","page":"Images","title":"Images","text":"","category":"section"},{"location":"images/#A-Julia-Julia-set:-ColorSchemes-and-Images","page":"Images","title":"A Julia Julia set: ColorSchemes and Images","text":"","category":"section"},{"location":"images/","page":"Images","title":"Images","text":"Here's an example of how you can use ColorSchemes when creating images with Images.jl. The code creates a Julia set and uses a pre-defined ColorScheme extracted from Vermeer's painting \"Girl with a Pearl Earring\" (shown at the right for reference).","category":"page"},{"location":"images/","page":"Images","title":"Images","text":"(Image: \"julia set\")","category":"page"},{"location":"images/","page":"Images","title":"Images","text":"using ColorSchemes, Images, FileIO\n# and possibly QuartzImageIO (macOS) and/or ImageMagick (Linux)\n\nfunction julia(z, c, maxiter::Int64)\n for n = 1:maxiter\n if abs(z) > 2\n return n\n end\n z = z^2 + c\n end\n return maxiter\nend\n\n# convert a value between oldmin/oldmax to equivalent value between newmin/newmax\nremap(value, oldmin, oldmax, newmin, newmax) = ((value - oldmin) / (oldmax - oldmin)) * (newmax - newmin) + newmin\n\nfunction draw(c, imsize;\n xmin = -1, ymin = -1, xmax = 1, ymax = 1,\n filename = \"/tmp/julia-set.png\")\n imOutput = zeros(RGB{Float32}, imsize, imsize)\n maxiterations = 200\n for col = range(xmin, stop=xmax, length=imsize)\n for row = range(ymin, stop=ymax, length=imsize)\n pixelcolor = julia(complex(row, col), c, maxiterations) / 256\n xpos = convert(Int, round(remap(col, xmin, xmax, 1, imsize)))\n ypos = convert(Int, round(remap(row, ymin, ymax, 1, imsize)))\n imOutput[xpos, ypos] = get(ColorSchemes.vermeer, pixelcolor)\n end\n end\n save(filename, imOutput)\nend\n\ndraw(-0.4 + 0.6im, 1200)","category":"page"},{"location":"basics/#Basics","page":"Basic usage","title":"Basics","text":"","category":"section"},{"location":"basics/#ColorScheme-objects","page":"Basic usage","title":"ColorScheme objects","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"When you start using ColorSchemes, it loads a set of pre-defined ColorSchemes in a dictionary called colorschemes.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"A ColorScheme is a Julia object which contains:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"an ordered array of colors (see Colors.jl)\na string defining a category\na string containing descriptive notes","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"To access one of the built-in colorschemes, use its symbol:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes # hide\nColorSchemes.leonardo ","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"or","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes # hide\ncolorschemes[:leonardo]","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"The display depends on your working environment. If you’re using a notebook or IDE environment, the colors in the colorscheme should appear as a swatch in a cell or in a Plots window. Otherwise, you’ll see the colors listed as RGB values:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"32-element Array{RGB{Float64},1}:\n RGB{Float64}(0.0548203,0.016509,0.0193152)\n RGB{Float64}(0.0750816,0.0341102,0.0397083)\n RGB{Float64}(0.10885,0.0336675,0.0261204)\n RGB{Float64}(0.100251,0.0534243,0.0497594)\n ...\n RGB{Float64}(0.620187,0.522792,0.216707)\n RGB{Float64}(0.692905,0.56631,0.185515)\n RGB{Float64}(0.681411,0.58149,0.270391)\n RGB{Float64}(0.85004,0.540122,0.136212)\n RGB{Float64}(0.757552,0.633425,0.251451)\n RGB{Float64}(0.816472,0.697015,0.322421)\n RGB{Float64}(0.933027,0.665164,0.198652)\n RGB{Float64}(0.972441,0.790701,0.285136)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"You can access the array of colors as:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"ColorSchemes.leonardo.colors","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"By default, the names of the built-in colorschemes aren’t imported. You can import the ones that you want:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> import ColorSchemes.leonardo\njulia> leonardo\n32-element Array{RGB{Float64},1}:\n RGB{Float64}(0.0548203,0.016509,0.0193152)\n RGB{Float64}(0.0750816,0.0341102,0.0397083)\n RGB{Float64}(0.10885,0.0336675,0.0261204)\n RGB{Float64}(0.100251,0.0534243,0.0497594)\n ...\n RGB{Float64}(0.757552,0.633425,0.251451)\n RGB{Float64}(0.816472,0.697015,0.322421)\n RGB{Float64}(0.933027,0.665164,0.198652)\n RGB{Float64}(0.972441,0.790701,0.285136)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"You can reference a single color in a scheme:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"leonardo[3]\n\n-> RGB{Float64}(0.10884977211887092,0.033667530751245296,0.026120424375656533)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Or you can ‘sample’ the scheme at any point between 0 and 1 using get or getindex:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"get(leonardo, 0.5)\n\n-> RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)\n\nleonardo[0.5]\n\n-> RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"With get you can resample an existing colorscheme, by passing a range:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"get(ColorSchemes.darkrainbow, range(0.0, 1.0, length=14))\n\n-> RGB{Float64}[\n RGB{Float64}(0.237736, 0.340215, 0.575113), \n RGB{Float64}(0.249978, 0.343813, 0.5620657), \n RGB{Float64}(0.259452, 0.386963, 0.464862), \n RGB{Float64}(0.272746, 0.439684, 0.3499807), \n ...\n RGB{Float64}(0.72987,0.239399,0.230961), \n RGB{Float64}(0.72987,0.239399,0.230961)]","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"and you can make a new scheme from this:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes, Colors # hide\nndr = ColorScheme(get(ColorSchemes.darkrainbow, range(0.0, 1.0, length=14)))","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"See below for more possibilities.","category":"page"},{"location":"basics/#The-colorschemes-dictionary","page":"Basic usage","title":"The colorschemes dictionary","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"The ColorSchemes module automatically provides a number of predefined schemes. All the colorschemes are stored in an exported dictionary, called colorschemes.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"colorschemes[:summer] |> show\n ColorScheme(\n ColorTypes.RGB{Float64}[\n RGB{Float64}(0.0,0.5,0.4),\n RGB{Float64}(0.01,0.505,0.4),\n RGB{Float64}(0.02,0.51,0.4),\n RGB{Float64}(0.03,0.515,0.4),\n ...\n RGB{Float64}(1.0,1.0,0.4)],\n \"matplotlib\",\n \"sampled color schemes, sequential linearly-increasing shades of green-yellow\")","category":"page"},{"location":"basics/#Finding-colorschemes","page":"Basic usage","title":"Finding colorschemes","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Use the findcolorscheme function to search through the pre-defined colorschemes. The string you provide can occur in the colorscheme’s name, in the category, or (optionally) in the notes. It’s interpreted as a case-insensitive regular expression.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> findcolorscheme(\"ice\")\n\ncolorschemes containing \"ice\"\n\n seaborn_icefire_gradient\n seaborn_icefire_gradient (notes) sequential, ice fire gradient...\n ice \n flag_is (notes) The flag of Iceland...\n botticelli \n botticelli (notes) palette from artist Sandro Bot...\n\n\n ...found 6 results for \"ice\"","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"The function returns a list of matching colorscheme names as symbols.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"findcolorscheme","category":"page"},{"location":"basics/#ColorSchemes.findcolorscheme","page":"Basic usage","title":"ColorSchemes.findcolorscheme","text":"findcolorscheme(str;\n search_notes=true)\n\nFind all colorschemes matching str. str is interpreted as a regular expression (case-insensitive).\n\nThis returns an array of symbols which are the names of matching schemes in the colorschemes dictionary.\n\njulia> findcolorscheme(\"ice\")\n\ncolorschemes containing \"ice\"\n\n seaborn_icefire_gradient\n seaborn_icefire_gradient (notes) sequential, ice fire gradient...\n ice\n flag_is (notes) The flag of Iceland...\n botticelli\n botticelli (notes) palette from artist Sandro Bot...\n\n\n ...found 6 results for \"ice\"\n\nTo read the notes of a built-in colorscheme cscheme:\n\ncolorschemes[:cscheme].notes\n\n\n\n\n\n","category":"function"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"If you prefer, you can ‘roll your own’ search.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"[k for (k, v) in ColorSchemes.colorschemes if occursin(r\"colorbrew\"i, v.category)]\n265-element Array{Symbol,1}:\n :BuPu_6\n :Spectral_4\n :RdYlGn_5\n ⋮\n :BrBG_8\n :Oranges_4","category":"page"},{"location":"basics/#Make-your-own-colorscheme","page":"Basic usage","title":"Make your own colorscheme","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Using Colors.jl, you can use the ColorScheme constructor to make a range of colors into a colorscheme.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Using Colors.jl's range():","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes # hide\ncs1 = ColorScheme(range(colorant\"red\", colorant\"green\", length=5))","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Using get():","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes # hide\ncs1 = ColorScheme(get(ColorSchemes.darkrainbow, range(0.3, 0.7, length=10)))","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Converting from a sequential palette:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes # hide\ncs1 = ColorScheme(reverse(Colors.sequential_palette(300, 100, logscale=true)))","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"From an array comprehension:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes # hide\nmygrays = ColorScheme([RGB{Float64}(i, i, i) for i in 0:0.1:1.0])","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"A logarithmic scheme:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes # hide\nColorScheme(get(ColorSchemes.darkrainbow, 10 .^ range(-2, stop=0, length=50)))","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Give it a category or some added notes if you want:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"mygrays = ColorScheme([RGB{Float64}(i, i, i) for i in 0:0.1:1.0],\n \"my useful schemes\", \"just some dull grey shades\")","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"although this scheme won’t be stored in the supplied colorschemes dictionary.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Another example: start with a two-color scheme, then building a gradient from the first color to the other.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"myscheme = ColorScheme([Colors.RGB(1.0, 0.0, 0.0), Colors.RGB(0.0, 1.0, 0.0)],\n \"custom\", \"twotone, red and green\")\nColorScheme([get(myscheme, i) for i in 0.0:0.01:1.0])","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Another way is to use the loadcolorscheme function used to build the colorschemes dictionary when the package is loaded:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes\nloadcolorscheme(:mygrays, [RGB{Float64}(i, i, i) for i in 0:0.1:1.0],\n \"useful schemes\", \"just some dull grey shades\")","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"and that will be added (temporarily) to the built-in dictionary.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> findcolorscheme(\"dull\")\n\ncolorschemes containing \"dull\"\n\n mygrays (notes) just some dull grey shades...\n\n\n ...found 1 result for \"dull\"","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"note: Note\nIf you want to make more advanced ColorSchemes, use linear-segment dictionaries or indexed lists, and use functions to generate color values, see the make_colorscheme() function in the ColorSchemeTools.jl package.","category":"page"},{"location":"basics/#For-CVD-(color-vision-deficient-or-\"color-blind\")-users","page":"Basic usage","title":"For CVD (color-vision deficient or \"color-blind\") users","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"This package contains a number of colorschemes that are designed to be helpful for people with some deficiencies in their perception of color:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"deuteranomaly (where green looks more red)\nprotanomaly (where red looks more green and less bright)\ntritanomaly (difficult to tell the difference between blue and green, and between yellow and red)\ntritanopia (difficult to tell the difference between blue and green, purple and red, and yellow and pink)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"findcolorscheme(\"cvd\")\n\ncolorschemes containing \"cvd\"\n\n tol_light (category) cvd\n tol_muted (category) cvd\n tol_bright (category) cvd\n okabe_ito (category) cvd\n mk_8 (category) cvd\n mk_12 (category) cvd\n mk_15 (category) cvd","category":"page"},{"location":"basics/#:tol_light","page":"Basic usage","title":":tol_light","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.tol_light # hide","category":"page"},{"location":"basics/#:tol_muted","page":"Basic usage","title":":tol_muted","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.tol_muted # hide","category":"page"},{"location":"basics/#:tol_bright","page":"Basic usage","title":":tol_bright","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.tol_bright # hide","category":"page"},{"location":"basics/#:okabe_ito","page":"Basic usage","title":":okabe_ito","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.okabe_ito # hide","category":"page"},{"location":"basics/#:mk_8","page":"Basic usage","title":":mk_8","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.mk_8 # hide","category":"page"},{"location":"basics/#:mk_12","page":"Basic usage","title":":mk_12","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.mk_12 # hide","category":"page"},{"location":"basics/#:mk_15","page":"Basic usage","title":":mk_15","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes # hide\nColorSchemes.mk_15 # hide","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Also, it's possible to generate schemes using Colors.distinguishable_colors():","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using Colors, ColorSchemes\nColorScheme(distinguishable_colors(10, transform=protanopic))","category":"page"},{"location":"basics/#More-about-color-sampling","page":"Basic usage","title":"More about color sampling","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"You can access the specific colors of a colorscheme by indexing (eg leonardo[2] or leonardo[5:end]). Or you can sample a ColorScheme at a point between 0.0 and 1.0 as if it were a continuous range of colors:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"get(leonardo, 0.5)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"returns","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"(Image: \"get example\")","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"The colors in the predefined ColorSchemes are usually sorted by LUV luminance, so this often makes sense.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"You can use get() with index data in arrays to return arrays of colors:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> get(leonardo, [0.0, 0.5, 1.0])\n3-element Array{RGB{Float64},1} with eltype ColorTypes.RGB{Float64}:\n RGB{Float64}(0.05482025926320272,0.016508952654741622,0.019315160361063788)\n RGB{Float64}(0.42637271063618504,0.28028983973265065,0.11258024276603132) \n RGB{Float64}(0.9724409077178674,0.7907008712807734,0.2851364857083522)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"(Image: \"get example 2\")","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"julia> simg = get(leonardo, rand(10, 16));\njulia> using FileIO\njulia> save(\"mosaic.png\", simg)","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"(Image: \"get example 1\")","category":"page"},{"location":"basics/#Matplotlib-compatibility","page":"Basic usage","title":"Matplotlib compatibility","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"Most of the color schemes in Matplotlib are available. The following code example gives a general picture.","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"using ColorSchemes\n\n# https://matplotlib.org/examples/color/colormaps_reference.html\n\nmatplotlibcmaps = Dict(\n :perceptuallyuniformsequential => [\n :viridis, :plasma, :inferno, :magma],\n :sequential => [\n :Greys_9, :Purples_9, :Blues_9, :Greens_9, :Oranges_9, :Reds_9,\n :YlOrBr_9, :YlOrRd_9, :OrRd_9, :PuRd_9, :RdPu_9, :BuPu_9,\n :GnBu_9, :PuBu_9, :YlGnBu_9, :PuBuGn_9, :BuGn_9, :YlGn_9],\n :sequential2 => [\n :binary, :gist_yarg, :gist_gray, :gray, :bone, :pink,\n :spring, :summer, :autumn, :winter, :cool, :Wistia,\n :hot, :afmhot, :gist_heat, :copper],\n :diverging => [\n :PiYG_11, :PRGn_11, :BrBG_11, :PuOr_11, :RdGy_11, :RdBu_11,\n :RdYlBu_11, :RdYlGn_11, :Spectral_11, :coolwarm, :bwr, :seismic],\n :cyclical => [\n :twilight, :twilight_shifted, :hsv],\n :qualitative => [\n :Pastel1_9, :Pastel2_8, :Paired_11, :Accent_8,\n :Dark2_8, :Set1_9, :Set2_8, :Set3_12,\n :tab10, :tab20, :tab20b, :tab20c],\n :miscellaneous => [\n :flag, :prism, :ocean, :gist_earth, :terrain, :gist_stern,\n :gnuplot, :gnuplot2, :CMRmap, :cubehelix, :brg, :hsv,\n :gist_rainbow, :rainbow, :jet, :nipy_spectral, :gist_ncar]\n )\n\nfor (k, v) in matplotlibcmaps\n println(\"$(rpad(k, 12)) $(length(v))\")\n for cs in v\n try\n c = ColorSchemes.colorschemes[cs]\n catch\n println(\"\\t$(rpad(cs, 12)) not currently in stock\")\n end\n end\nend","category":"page"},{"location":"basics/#Alpha-transparency","page":"Basic usage","title":"Alpha transparency","text":"","category":"section"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"To convert a colorscheme to one with transparency, you could use a function like this:","category":"page"},{"location":"basics/","page":"Basic usage","title":"Basic usage","text":"function colorscheme_alpha(cscheme::ColorScheme, alpha::T = 0.5; \n ncolors=12) where T<:Real\n return ColorScheme([RGBA(get(cscheme, k), alpha) for k in range(0, 1, length=ncolors)])\nend\n\ncolors = colorscheme_alpha(ColorSchemes.ice, ncolors=12)","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"# this code will display all the schemes in a category, as an SVG.\n# Use in this docs/src/catalogue.md file as\n# ```@example catalog\n# using Luxor, ColorSchemes # hide\n# ColorSchemeCategory(\"cmocean\") # hide\n# ```\n# which displays the \"cmocean\" category\n\nusing Luxor, ColorSchemes\n\nstruct ColorSchemeGroup\n name::String\nend\n\nfunction generate_scheme_svg(schemename;\n swatchwidth = 800,\n swatchheight = 20)\n # create swatch\n cols = colorschemes[schemename].colors\n l = length(cols)\n Drawing(swatchwidth, swatchheight, :svg)\n origin()\n t = Tiler(swatchwidth, swatchheight, 1, l, margin=0)\n setline(0.5)\n for (i, c) in enumerate(cols)\n sethue(c)\n box(t, i, :fillstroke)\n end\n finish()\n\n swatch = svgstring()\n\n # fill the template\n schemetemplate = \"\"\"\n \n
:$(schemename)
\n
\n
$(swatch)
\n \"\"\"\n return schemetemplate\nend\n\nfunction generate_schemes_in_category(category)\n iobuffer = IOBuffer()\n\n write(iobuffer, \"\"\"\n
\n \"\"\")\n\n schemes = filter(s -> occursin(category, colorschemes[s].category), collect(keys(colorschemes)))\n for s in sort(schemes, lt = (s1, s2) -> lowercase(string(s1)) < lowercase(string(s2)))\n write(iobuffer, generate_scheme_svg(s))\n end\n write(iobuffer, \"\"\"\n
\n \"\"\")\n\n return String(take!(iobuffer))\nend\n\nfunction generate_schemes_matching_notes_string(str)\n iobuffer = IOBuffer()\n\n write(iobuffer, \"\"\"\n
\n \"\"\")\n\n schemes = filter(s -> occursin(str, colorschemes[s].notes), collect(keys(colorschemes)))\n for s in sort(schemes, lt = (s1, s2) -> lowercase(string(s1)) < lowercase(string(s2)))\n write(iobuffer, generate_scheme_svg(s))\n end\n write(iobuffer, \"\"\"\n
\n \"\"\")\n\n return String(take!(iobuffer))\nend\n\nfunction Base.show(io::IO, m::MIME\"text/html\", category::ColorSchemeCategory)\n print(io, generate_schemes_in_category(category.name))\nend\n\nfunction Base.show(io::IO, m::MIME\"text/html\", group::ColorSchemeGroup)\n print(io, generate_schemes_matching_notes_string(group.name))\nend","category":"page"},{"location":"catalogue/#Catalogue-of-ColorSchemes","page":"Catalogue","title":"Catalogue of ColorSchemes","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"At the REPL you can search for colorschemes by name:","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"findcolorscheme(\"julia\")","category":"page"},{"location":"catalogue/#cmocean","page":"Catalogue","title":"✦ cmocean","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From \"Beautiful colormaps for oceanography\": cmocean","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"cmocean\") # hide","category":"page"},{"location":"catalogue/#scientific","page":"Catalogue","title":"✦ scientific","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From Scientific colormaps","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"scientific\") # hide","category":"page"},{"location":"catalogue/#matplotlib","page":"Catalogue","title":"✦ matplotlib","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From matplot","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"matplotlib\") # hide","category":"page"},{"location":"catalogue/#colorbrewer","page":"Catalogue","title":"✦ colorbrewer","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From ColorBrewer","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"colorbrewer\") # hide","category":"page"},{"location":"catalogue/#gnuplot","page":"Catalogue","title":"✦ gnuplot","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From GNUPlot","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"gnuplot\") # hide","category":"page"},{"location":"catalogue/#colorcet","page":"Catalogue","title":"✦ colorcet","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From \"collection of perceptually accurate colormaps\"","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"colorcet\") # hide","category":"page"},{"location":"catalogue/#Seaborn","page":"Catalogue","title":"✦ Seaborn","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From \"colorschemes used by Seaborn, a Python data visualization library based on matplotlib.\"","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"seaborn\") # hide","category":"page"},{"location":"catalogue/#ggthemes/tableau","page":"Catalogue","title":"✦ ggthemes/tableau","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"From \"ggthemes tableau palettes\"","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"tableau\") # hide","category":"page"},{"location":"catalogue/#Color-Vision-Deficient-friendly-schemes","page":"Catalogue","title":"✦ Color-Vision Deficient-friendly schemes","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Colorschemes designed with color-vision deficient users in mind, by authors such as Paul Tol, Masataka Okabe, Kei Ito, and Martin Krzywinski. This list also includes schemes with \"cvd\" in the Notes field.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"cvd\") # hide\nColorSchemeGroup(\"cvd\") # hide","category":"page"},{"location":"catalogue/#Flags","page":"Catalogue","title":"✦ Flags","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Colors extracted from flags of different countries and regions, downloaded from Flagpedia. Intended to represent these regions in visualizations, but not necessarily effective. Many flags have similar colorschemes. The flags are named according to the region's ISO3166 two-letter abbreviation (often the same as top-level WWW domain), with any hyphens removed.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"flags\") # hide","category":"page"},{"location":"catalogue/#MetBrewer","page":"Catalogue","title":"✦ MetBrewer","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Palettes inspired by works at the Metropolitan Museum of Art in New York. See Blake Mills' github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"MetBrewer\") # hide","category":"page"},{"location":"catalogue/#Pacific-North-West","page":"Catalogue","title":"✦ Pacific North West","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"The colors of Washington State and the Pacific Northwest of the USA. See Jake Lawlor's github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"PNW Pacific North West\") # hide","category":"page"},{"location":"catalogue/#Wes-Anderson","page":"Catalogue","title":"✦ Wes Anderson","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Palettes derived from the films of Wes Anderson. See Karthik's github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"Wes Anderson\") # hide","category":"page"},{"location":"catalogue/#Ghibli","page":"Catalogue","title":"✦ Ghibli","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Palettes derived from the films of Studio Ghibli. See Ewenme's github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"Ghibli\") # hide","category":"page"},{"location":"catalogue/#Feathers","page":"Catalogue","title":"+ Feathers","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"Palattes derived from the plumage of Australian birds. See Shandiya's github repository.","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"Feathers\") # hide","category":"page"},{"location":"catalogue/#general-and-miscellaneous","page":"Catalogue","title":"✦ general and miscellaneous","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"general\") # hide","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"nord\") # hide","category":"page"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"kindlmann\") # hide","category":"page"},{"location":"catalogue/#Julia-logo-colorschemes","page":"Catalogue","title":"✦ Julia logo colorschemes","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"julia\") # hide","category":"page"},{"location":"catalogue/#Pride-colorschemes","page":"Catalogue","title":"✦ Pride colorschemes","text":"","category":"section"},{"location":"catalogue/","page":"Catalogue","title":"Catalogue","text":"using Luxor, ColorSchemes # hide\nColorSchemeCategory(\"pride\") # hide","category":"page"},{"location":"plotting/#Plotting","page":"Plotting","title":"Plotting","text":"","category":"section"},{"location":"plotting/#UnicodePlots.jl","page":"Plotting","title":"UnicodePlots.jl","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"The heatmap() function in UnicodePlots.jl can use colorschemes. You have to supply the colors as an array of floating-point numbers first:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"... colormap = [(x.r, x.g, x.b) for x in ColorSchemes.leonardo.colors]","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"For example:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"heatmap(z::AbstractMatrix; title = \"Hot!\",\n colormap = [(x.r, x.g, x.b) for x in ColorSchemes.leonardo.colors])","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"heatmap\")","category":"page"},{"location":"plotting/#Plots.jl","page":"Plotting","title":"Plots.jl","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"Plots.jl supports all colorschemes from ColorSchemes.jl. They can be used as a gradient or as a palette and are passed as a symbol holding their name to cgrad or palette.","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"This renaissance-looking plot uses the leonardo scheme:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Plots\n\nx = 1:0.3:20\ny = x\nf(x, y) = begin\n sin(x) + cos(y)\n end\ncontour(x, y, f, fill=true, c = :leonardo)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"contour\")","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(You can use c as a short cut for seriescolor.)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"With other plots, use the palette keyword:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using ColorSchemes\n\nplot(Plots.fakedata(100, 20),\n w=4,\n background_color=ColorSchemes.vermeer[1],\n palette=:vermeer)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"palette\")","category":"page"},{"location":"plotting/#Gadfly","page":"Plotting","title":"Gadfly","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"Here's how you can use ColorSchemes in Gadfly:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Gadfly, ColorSchemes\nx = repeat(collect(1:20), inner=[20]);\ny = repeat(collect(1:20), outer=[20]);\nplot(x=x, y=y,\n color=x+y,\n Geom.rectbin,\n Scale.ContinuousColorScale(p -> get(ColorSchemes.sunset, p)))","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"gadfly\")","category":"page"},{"location":"plotting/#Makie","page":"Plotting","title":"Makie","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"If you use Makie.jl you can pass the colors in a ColorScheme directly to the colormap keyword.","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Makie, ColorSchemes\nN = 20\nx = LinRange(-0.3, 1, N)\ny = LinRange(-1, 0.5, N)\nz = x .* y'\nimage(x, y, z, colormap = ColorSchemes.picasso.colors)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"makie\")","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"You can display all the colorschemes using Makie by letting the code browse through the colorschemes dictionary:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Makie, ColorSchemes\n\nh = 0.0\noffset = 0.1\nscene = Scene()\ncam2d!(scene)\nplot = map(collect(keys(colorschemes))) do cmap\n global h\n c = to_colormap(colorschemes[cmap].colors)\n cbar = image!(\n scene,\n range(0, stop = 10, length = length(c)),\n range(0, stop = 1, length = length(c)),\n reshape(c, (length(c), 1)),\n show_axis = false\n )[end]\n text!(\n scene,\n string(cmap, \":\"),\n position = Point2f0(-0.1, 0.5 + h),\n align = (:right, :center),\n show_axis = false,\n textsize = 0.4\n )\n translate!(cbar, 0, h, 0)\n h -= (1 + offset)\nend\nscene","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"makie all colorschemes\")","category":"page"},{"location":"plotting/#Winston","page":"Plotting","title":"Winston","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"If you prefer Winston.jl for plotting, you can use ColorSchemes with imagesc:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using Winston, ColorSchemes\nklimt = ColorSchemes.klimt.colors\nWinston.colormap(klimt)\nWinston.imagesc(reshape(1:10000,100,100))","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"winston klimt\")","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"Sometimes you'll want a smoother gradient with more colors. You can use get(scheme, n) to generate a more detailed array of colors, varying n from 0 to 1 by 0.001:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"brasstones = ColorSchemes.brass\nbrasstonesmooth = [get(brasstones, i) for i in 0:0.001:1]\nWinston.colormap(brasstonesmooth)\nWinston.imagesc(reshape(1:10000,100,100))","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"winston brass tones)","category":"page"},{"location":"plotting/#PyPlot","page":"Plotting","title":"PyPlot","text":"","category":"section"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"ColorSchemes can be used with the cmap keyword in PyPlot:","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"using PyPlot, Distributions, ColorSchemes\n\nsolar = ColorSchemes.solar.colors\n\nn = 100\nx = range(-3, stop=3, length=n)\ny = range(-3, stop=3, length=n)\n\nxgrid = repeat(x', n, 1);\nygrid = repeat(y, 1, n);\nz = zeros(n, n);\n\nfor i in 1:n\n for j in 1:n\n z[i, j] = 2sin(x[i]) * 2cos(y[j])\n end\nend\n\nfig = PyPlot.figure(\"pyplot_surfaceplot\",figsize=(10,10))\n\nusing3D()\nax = fig.add_subplot(2, 1, 1, projection = \"3d\")\n\nax.plot_surface(xgrid, ygrid, z, rstride=2,edgecolors=\"k\",\n cstride=2,\n cmap=ColorMap(solar),\n alpha=0.8,\n linewidth=0.25)\n\ndisplay(fig)","category":"page"},{"location":"plotting/","page":"Plotting","title":"Plotting","text":"(Image: \"pyplot\")","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"DocTestSetup = quote\n using ColorSchemes, Colors\nend","category":"page"},{"location":"#Introduction-to-ColorSchemes","page":"Introduction","title":"Introduction to ColorSchemes","text":"","category":"section"},{"location":"","page":"Introduction","title":"Introduction","text":"This package provides a collection of colorschemes:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"scientifically devised colorschemes from ColorBrewer, CMOcean, ScientificColorMaps, ColorCet, and Seaborn\npopular favourites such as viridis, inferno, and magma from MATPlotLib\nvariously themed colorschemes such as sunset, coffee, neon, and pearl\nartistic colorschemes, such as leonardo, vermeer, picasso, Degas, Hiroshige, ","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"Note that the schemes contained here are a mixture:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"some are high quality color maps with consistent perceptual contrast over their full range\nothers are designed for general purpose and informal graphics work","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"Choose colorschemes with care! See the Good practice section, and also refer to Peter Kovesi's PerceptualColourMaps package, or to Fabio Crameri's Scientific Colour Maps for technical information.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"This package relies on the Colors.jl package.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"If you want to make more advanced ColorSchemes, use linear-segment dictionaries or indexed lists, and use functions to generate color values, see the make_colorscheme() function in the ColorSchemeTools.jl package.","category":"page"},{"location":"#Installation-and-basic-usage","page":"Introduction","title":"Installation and basic usage","text":"","category":"section"},{"location":"","page":"Introduction","title":"Introduction","text":"Install the package as follows:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"import Pkg\nPkg.add(\"ColorSchemes\")","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"or, at the REPL:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"] add ColorSchemes","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"Usage:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"using ColorSchemes\n\nColorSchemes.Purples_5 \n# => a ColorScheme \n\ncolorschemes[:Purples_5]\n# => a ColorScheme \n\nColorSchemes.Purples_5.colors\n# => array of five RGB colors\n\nColorSchemes.Purples_5.colors[3]\n# => the third color in the colorscheme\n\nget(ColorSchemes.Purples_5, 0.5)\n# => the midway point of the colorscheme \n\ncolorschemes\n# => Dict{Symbol, ColorScheme} with 1150 entries\n\nfindcolorscheme(\"purple\")\n# => display list of matching schemes\n\nColorScheme([colorant\"red\", colorant\"green\", colorant\"blue\"])\n# new colorscheme from Colors.jl named colors\n\nget(ColorSchemes.darkrainbow, range(0.0, 1.0, length=20)) |> ColorScheme\n# new colorscheme by resampling existing","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"Original version by cormullion.","category":"page"},{"location":"#Contributing-a-new-colorscheme","page":"Introduction","title":"Contributing a new colorscheme","text":"","category":"section"},{"location":"","page":"Introduction","title":"Introduction","text":"If you think a new colorscheme would be a great addition for you and for Julians everywhere, you can contribute it as follows:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"1 Add a file to the data/ directory. The file should be a Julia file, with a .jl suffix.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"2 Inside the file, define a colorscheme in this format, which calls loadcolorscheme:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"loadcolorscheme(:mynewcolorscheme, [\n RGB(0.0, 0.0, 0.0),\n RGB(0.5, 0.5, 0.5),\n RGB(1.0, 1.0, 1.0),\n ], \n \"category for my new scheme\", # the category\n \"black, white, and grey\" # some descriptive keywords\n )","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"The new name - here mynewcolorscheme - should be a valid Julia variable name.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"3 If you're adding the new colorscheme to an existing category, it will appear in the catalog document automatically.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"4 Otherwise, to add a new category to the catalog (which will add all the colorschemes in that category), add this code to catalogue.md:","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":" ```@example catalog\n using Luxor, ColorSchemes # hide\n ColorSchemeCategory(\"category for my new scheme\") # hide\n ```","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"5 If there's a license file, add it to data/ as well.","category":"page"},{"location":"#Documentation","page":"Introduction","title":"Documentation","text":"","category":"section"},{"location":"","page":"Introduction","title":"Introduction","text":"This documentation was built using Documenter.jl.","category":"page"},{"location":"","page":"Introduction","title":"Introduction","text":"using Dates # hide\nprintln(\"Documentation built $(Dates.now()) with Julia $(VERSION)\") # hide","category":"page"}] }