From d48d2faec16817c7e481617e5a86e60b06308f98 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Thu, 9 May 2024 09:00:01 +0000 Subject: [PATCH] build based on caf21df --- dev/.documenter-siteinfo.json | 2 +- dev/basics/index.html | 6 +- dev/catalogue/index.html | 330 +++++++++++++++++++++++++++++++++- dev/finding/index.html | 4 +- dev/functionindex/index.html | 2 +- dev/goodpractice/index.html | 2 +- dev/images/index.html | 2 +- dev/index.html | 2 +- dev/objects.inv | Bin 1142 -> 1153 bytes dev/plotting/index.html | 2 +- dev/references/index.html | 2 +- dev/search_index.js | 2 +- 12 files changed, 341 insertions(+), 15 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 3058850..bb1edec 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.3","generation_timestamp":"2024-05-08T10:03:36","documenter_version":"1.4.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.3","generation_timestamp":"2024-05-09T08:59:49","documenter_version":"1.4.1"}} \ No newline at end of file diff --git a/dev/basics/index.html b/dev/basics/index.html index 6d8d1b3..e5a0c99 100644 --- a/dev/basics/index.html +++ b/dev/basics/index.html @@ -79,7 +79,7 @@ # Also works with PerceptualColourMaps using PerceptualColourMaps # warning, installs PyPlot, PyCall, LaTeXStrings -img4 = get(PerceptualColourMaps.cmap("R1"), rand(10,10))source
get(cs::ColorScheme, g::Color{T,1} where T<:Union{Bool, AbstractFloat, FixedPoint})

Return the color in cs that corresponds to the gray value g.

source

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
+img4 = get(PerceptualColourMaps.cmap("R1"), rand(10,10))
source
get(cs::ColorScheme, g::Color{T,1} where T<:Union{Bool, AbstractFloat, FixedPoint})

Return the color in cs that corresponds to the gray value g.

source

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),
@@ -114,7 +114,7 @@
   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
@@ -476,4 +476,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 3dc3ee9..a181bd2 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

:algae
@@ -60578,6 +60578,332 @@

✦ We

+

✦ Ghibli

Palettes derived from the films of Studio Ghibli. See Ewenme's github repository.

+
:KikiDark
+
+ + + + + + + + + +
+
:KikiLight
+
+ + + + + + + + + +
+
:KikiMedium
+
+ + + + + + + + + +
+
:LaputaDark
+
+ + + + + + + + + +
+
:LaputaLight
+
+ + + + + + + + + +
+
:LaputaMedium
+
+ + + + + + + + + +
+
:MarnieDark1
+
+ + + + + + + + + +
+
:MarnieDark2
+
+ + + + + + + + + +
+
:MarnieLight1
+
+ + + + + + + + + +
+
:MarnieLight2
+
+ + + + + + + + + +
+
:MarnieMedium1
+
+ + + + + + + + + +
+
:MarnieMedium2
+
+ + + + + + + + + +
+
:MononokeDark
+
+ + + + + + + + + +
+
:MononokeLight
+
+ + + + + + + + + +
+
:MononokeMedium
+
+ + + + + + + + + +
+
:PonyoDark
+
+ + + + + + + + + +
+
:PonyoLight
+
+ + + + + + + + + +
+
:PonyoMedium
+
+ + + + + + + + + +
+
:SpiritedDark
+
+ + + + + + + + + +
+
:SpiritedLight
+
+ + + + + + + + + +
+
:SpiritedMedium
+
+ + + + + + + + + +
+
:TotoroDark
+
+ + + + + + + + + +
+
:TotoroLight
+
+ + + + + + + + + +
+
:TotoroMedium
+
+ + + + + + + + + +
+
:YesterdayDark
+
+ + + + + + + + + +
+
:YesterdayLight
+
+ + + + + + + + + +
+
:YesterdayMedium
+
+ + + + + + + + + +
+

✦ general and miscellaneous

:CMRmap
@@ -64744,4 +65070,4 @@

« IntroductionBasic usage »

+
diff --git a/dev/finding/index.html b/dev/finding/index.html index f6a9043..5341e62 100644 --- a/dev/finding/index.html +++ b/dev/finding/index.html @@ -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 elevation in the United States 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. source.

using Images, FileIO
+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 elevation in the United States 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. source.

using Images, FileIO
 img = download("https://www.nasa.gov/images/content/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]
@@ -52,4 +52,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 b4f59ad..f2d9efa 100644 --- a/dev/functionindex/index.html +++ b/dev/functionindex/index.html @@ -1,2 +1,2 @@ -Index · ColorSchemes
+Index · ColorSchemes
diff --git a/dev/goodpractice/index.html b/dev/goodpractice/index.html index 588b340..80f847c 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 f0f1ada..4ad8e22 100644 --- a/dev/images/index.html +++ b/dev/images/index.html @@ -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 853b65a..52d9a49 100644 --- a/dev/index.html +++ b/dev/index.html @@ -31,4 +31,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("all_my_new_colorschemes") # 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-05-08T10:03:32.744 with Julia 1.10.3
+ ```

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

Documentation

This documentation was built using Documenter.jl.

Documentation built 2024-05-09T08:59:46.104 with Julia 1.10.3
diff --git a/dev/objects.inv b/dev/objects.inv index 488cb8c9328f6348c1d4eb379bb2f45ae7dd8b81..ab635df348457194875ff3545d3cdb0bed19b704 100644 GIT binary patch delta 998 zcmV$lM48OE+WAp?+-WkJq>Yyzkc1@I5TO!a z9Q9ke&WH6&dI7!wQlz^PMdF+T+$XNgGw}nA&6b%?0p9~W)ei)BI%#H!?LLtokyCYxjiG@Qq*_t+Rc>Nj!}t!|!vrr;`BzDu082vUQnz`(@ud z(E`EUgMAf$l_Iy2D-TsX5o%!6$tfUPTCJXx+-z-(tX*|7`*77EYIst-iLW8Z?zb{g zGRAh%q9gqK&rhg8?2oO$%5CXZ?1aHgdeeAuIKJ5_5CuXCbQD%cqLxINN8+(!6F!oR z0|+vYHee5J06KCM0)Ow;J6+(-w_7~(T>LH#tz#zEGL;k+m*aA?#Uc=-x7p&CT9o)ee25MMEgNV#J`8vsTZtkSds}jaWiHpc*hzbsPN!&nKTsw*^N8PSMP7s$+Jl9h+|G6fIPR9(8?(KyR?jOI@1EP&7`w>0d_!&=4w9p&_spPbFm-e%6KE z;-fJ3jV@3Vz<(3K5!kIHJ2r#uhi!~PD0}f}yQ~LX;cumqy#6)9E-}a*gFMghp=-je zO5KJ}27GedsKOO^SpDlZ3lr4&$G2UOxf!9!f#cRxNV!n zx}Zm<4tTT!4t5MxV5kC3L%h{#xuX^CTHv50ko_)@l3{+|% zm|b_1%8?R7_Gd0ror(Wr;#3a1_0_?tOje58Z#mk6=Vs3fk*A}VuSY_NWXs*l)BD9} ztEpC9xqn)>sgel=Vz;LVCQ=P9m#{-Oc!=SW&NT52f zFVrL$7QYDEo{~N5-({I#a($Vx@T2IhKQ+GvfiLPC+-| zVl)Sj+7{2kG+4~fd^TUZ;oz>% delta 988 zcmV<210(!_3HAt(gMV(@I27IUD=wNCNESCnT@=W8m&c??(H6$^k!3(hw9SMTJtEcA z^DVQU51TKUOX@{RmNFa563;m#?_1`X_yxvh%S@+$ZvpOeTj;Dzt<*V7x#dc4N)bZZ zk8`+b{<4G{nVJw*eVN0xdqQdWMzD?6*}mW;o<@@4_c?r^HXF)#WT;vpVH7eW`ANWQ%S}~`u3(;N)*xFoMUN3VUAz35t}V8$K_^=MIcCTv&C<< zDDi>#5FG|uHqdf>81Ou{5=AQZw&V)ST&{JollCwjBpn4hN)-va(u!;{5Gn++8+Vqk z-rlH_Cz09_!<<3@g&N8}^JjqvT^6WcBA<_mI085V5Fzw7oqvSNiA+kDcgQgpFXMXt zG#wl`5Ij=*{TJWu72Rn~j&X_`LCBwEYH@Zx5|0xc3J3Br)CkaP@CXQ1*-}4~=A*QF z)bt$!{e@*->e5sfMdQSqnsn3w4WYU!Gz7NdsiX+QFS@W>d=REr1-d#+GXMVl57Y$k z1aJg)E9oAa!GHF{(nKzlJ%6;7(*v&XW2q#se~qw93}VM1&ojL53TvxUm)4U3pA0vu za0MP#|GLe>Ks7+nrdEFz_PP)+qIktPEslNQ*;*Z@?&|l#A61dKZHvUZphu<-c(eiz zb_`Wur~*wvywz#BqZRH-;2Y zfKz}-fw}f*E}qnsVJhd*E%ihz7#O1RqGR=1&1QY{3t>u&lul48id z=Q7oq_&-;iieb0DIyjZdOi}wSM_cgR?0F&bbhP<;B!oz|+&w?OU5u8RYSpEyb(<=g zkRx_`@_%3=)u6eA6}rJgg!lVhPHlJTY?2#tsq%5+)6_%I&vZu|)q#DYCcyyshoJ2# z*t32o8&;%MILwWh+FR@Wq_y4?>_O6*`biQi#k0<_80?H04>)xQx}g=L*>?19@q9~z z#r(`i^R*iu&R;1rg;)z0DlQ(0I$PXP8|&z9Xi*sm_-Zt^OO3RgU>;f8clk diff --git a/dev/plotting/index.html b/dev/plotting/index.html index 5449de8..6afe79b 100644 --- a/dev/plotting/index.html +++ b/dev/plotting/index.html @@ -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 0c01c8d..9a570fa 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 329c3a1..b9d6e9c 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 elevation in the United States 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. source.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"using Images, FileIO\nimg = download(\"https://www.nasa.gov/images/content/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 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)\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 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
:$(schemename)
\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)\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)\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/#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":"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:","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 \"my new schemes\", # 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(\"all_my_new_colorschemes\") # 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/#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 elevation in the United States 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. source.","category":"page"},{"location":"finding/","page":"Finding colors","title":"Finding colors","text":"using Images, FileIO\nimg = download(\"https://www.nasa.gov/images/content/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 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)\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 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
:$(schemename)
\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)\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)\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/#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":"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:","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 \"my new schemes\", # 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(\"all_my_new_colorschemes\") # 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"}] }