ColorTools - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Graphics : Packages : ColorTools : ColorTools/SortPalette

ColorTools

 SortPalette
 sort colors into a good palette order

 Calling Sequence SortPalette(colors) SortPalette(colors, opts)

Parameters

 colors - a list of colors in formats recognized by ColorTools opts - optional arguments for the Distance computations

Description

 • The SortPalette command sorts a list of colors so that the earlier colors are as far apart as possible in the sense of the metric used by the Distance command.  In the resulting palette, the earlier colors will be more visually distinguishable, which can be useful when using the palettes for plotting.
 • The first color of the list colors will remain the first color.
 • Arguments other than the list of colors will be passed as options to the color Distance command.

Examples

 > $\mathrm{with}\left(\mathrm{ColorTools}\right):$
 > $\mathrm{origp}≔\left[{\mathrm{GetPalette}\left("HTML"\right)}_{[]}\right]:$
 > ${\mathrm{origp}}_{1..5}$
 $\left[{⟨}\colorbox[rgb]{0,0,0}{{RGB : Black}}{⟩}{,}{⟨}\colorbox[rgb]{0.411764705882353,0.411764705882353,0.411764705882353}{RGB : Dim Gray}{⟩}{,}{⟨}\colorbox[rgb]{0.501960784313725,0.501960784313725,0.501960784313725}{RGB : Gray}{⟩}{,}{⟨}\colorbox[rgb]{0.662745098039216,0.662745098039216,0.662745098039216}{RGB : Dark Gray}{⟩}{,}{⟨}\colorbox[rgb]{0.752941176470588,0.752941176470588,0.752941176470588}{RGB : Silver}{⟩}\right]$ (1)
 > $\mathrm{randp}≔{\mathrm{origp}}_{\mathrm{combinat}[\mathrm{randperm}]\left(\left[\mathrm{}\left(1..\mathrm{nops}\left(\mathrm{origp}\right)\right)\right]\right)}:$
 > ${\mathrm{randp}}_{1..5}$
 $\left[{⟨}\colorbox[rgb]{1,0.894117647058824,0.709803921568627}{RGB : Moccasin}{⟩}{,}{⟨}\colorbox[rgb]{0.686274509803922,0.933333333333333,0.933333333333333}{RGB : Pale Turquoise}{⟩}{,}{⟨}\colorbox[rgb]{1,0.411764705882353,0.705882352941177}{RGB : Hot Pink}{⟩}{,}{⟨}\colorbox[rgb]{0.870588235294118,0.72156862745098,0.529411764705882}{RGB : Burlywood}{⟩}{,}{⟨}\colorbox[rgb]{0.501960784313725,0.501960784313725,0}{RGB : Olive}{⟩}\right]$ (2)
 > $\mathrm{sortedp}≔\mathrm{SortPalette}\left(\mathrm{randp}\right):$
 > ${\mathrm{sortedp}}_{1..5}$
 $\left[{⟨}\colorbox[rgb]{1,0.894117647058824,0.709803921568627}{RGB : Moccasin}{⟩}{,}{⟨}\colorbox[rgb]{0,0,1}{{RGB : Blue}}{⟩}{,}{⟨}\colorbox[rgb]{0,0.392156862745098,0}{{RGB : Dark Green}}{⟩}{,}{⟨}\colorbox[rgb]{1,0,0}{{RGB : Red}}{⟩}{,}{⟨}\colorbox[rgb]{0,1,0}{RGB : Lime}{⟩}\right]$ (3)
 > $\mathrm{with}\left(\mathrm{plots}\right):$
 > $\mathrm{display}\left(\mathrm{Array}\left(\left[\mathrm{display}\left(\mathrm{seq}\left(\mathrm{plot}\left(xi,x=5..10,\mathrm{thickness}=4,\mathrm{color}={\mathrm{origp}}_{i}\right),i=1..5\right)\right),\mathrm{display}\left(\mathrm{seq}\left(\mathrm{plot}\left(xi,x=5..10,\mathrm{thickness}=4,\mathrm{color}={\mathrm{randp}}_{i}\right),i=1..5\right)\right),\mathrm{display}\left(\mathrm{seq}\left(\mathrm{plot}\left(xi,x=5..10,\mathrm{thickness}=4,\mathrm{color}={\mathrm{sortedp}}_{i}\right),i=1..5\right)\right)\right]\right),\mathrm{size}=\left[400,200\right]\right)$   > 

Compatibility

 • The ColorTools[SortPalette] command was introduced in Maple 18.
 • For more information on Maple 18 changes, see Updates in Maple 18.

 See Also