Skip to content

foresight_palette ​

foresight_palette, gnuplot color palettes: gray levels (0 to 1) to colors, for images and color boxes.

As gnuplot 6.0 (values checked against its test palette tables): rgbformulae R,G,B (the default 7,5,15: sqrt, cube, sin 2pi) with gnuplot's 37 formulae, a negative number meaning the formula of 1 - gray; defined (v1 c1, ...) interpolating linearly in RGB between colors (#rrggbb or a gnuplot color name) at increasing values (the script's file palettes too, through palette_gradient); gray (gray to the power 1/1.5, gnuplot's gamma); viridis; negative reverses the gray axis; maxcolors N quantizes: band k = floor(gray N) takes the color of gray k / (N - 1). Channels are rounded to 8 bits. color (after gray, say) restores the last palette set by rgbformulae, defined or a name, else the default. cubehelix [start S] [cycles C] [saturation S] (gnuplot's defaults 0.5, -1.5, 1 at each cubehelix): Green's helix, angle 2pi (S/3 + C gray), lightness gray^(1/1.5) (gamma 1.5), amplitude saturation lightness (1 - lightness)/2. Beyond gnuplot, any named palette of foresight_colormaps (batlow, vik, magma, cividis, ..., viridis), matched case-insensitively: a 256-color table, gray g taking its color nint(255 g), so maxcolors N gives the N colors nint(255 k / (N - 1)), Crameri's discrete palettes.

Source: src/lib/foresight_palette.F90

Dependencies

Contents ​

Variables ​

NameTypeAttributesDescription
PAL_FORMULAEinteger(kind=I4P)parameterrgbformulae.
PAL_DEFINEDinteger(kind=I4P)parameterdefined.
PAL_GRAYinteger(kind=I4P)parametergray.
PAL_TABLEinteger(kind=I4P)parameterA named palette of foresight_colormaps (viridis, batlow, ...).
PAL_CUBEHELIXinteger(kind=I4P)parametercubehelix.
CUBEHELIX_DEFAULTreal(kind=R8P)parametergnuplot's start, cycles, saturation.
PIreal(kind=R8P)parameterPi.
COLOR_NAMES_COUNTinteger(kind=I4P)parametergnuplot's predefined colors (show colornames).
COLOR_NAMEScharacter(len=17)parametergnuplot 6.0 color names.
COLOR_VALUEScharacter(len=6)parameterTheir RRGGBB values.

Derived Types ​

palette_object ​

Color palette.

Components

NameTypeAttributesDescription
modeinteger(kind=I4P)Palette kind.
formulaeinteger(kind=I4P)gnuplot rgbformulae, R, G, B.
negativelogicalGray axis reversed.
maxcolorsinteger(kind=I4P)Colors of a quantized palette, 0 for continuous.
hsvlogicalmodel HSV: the components are hue, saturation, value.
cmylogicalmodel CMY: the components are cyan, magenta, yellow.
tableinteger(kind=I4P)Named palette (foresight_colormaps index), PAL_TABLE.
cubehelixreal(kind=R8P)cubehelix start, cycles, saturation.
gammareal(kind=R8P)Gamma of the gray and cubehelix palettes (gamma G).
color_modeinteger(kind=I4P)Mode color restores: the last set by rgbformulae, defined or a name (as gnuplot's last gradient or formulae).
positionsreal(kind=R8P)allocatabledefined positions, increasing.
colorsreal(kind=R8P)allocatabledefined colors (RGB 0..1, position).

Type-Bound Procedures

NameAttributesDescription
is_defaultpass(self)Whether the palette is gnuplot's default.
rgbpass(self)Color of a gray level, 8-bit channels.
rgb1pass(self)Color of a gray level, channels 0..1.

Subroutines ​

named_color ​

Channels of a palette color, as gnuplot set palette defined: #rrggbb, 0xrrggbb or one of gnuplot's 111 color names (show colornames: red, dark-green, gray90, ..., case sensitive).

Attributes: pure

fortran
subroutine named_color(name, c, ok)

Arguments

NameTypeIntentAttributesDescription
namecharacter(len=*)inColor.
cinteger(kind=I4P)outRed, green, blue, 0..255.
oklogicaloutColor known.

Call graph

gnuplot_color ​

SVG color of a gnuplot color string, as lc rgb "spec": one of gnuplot's 111 color names (show colornames, case sensitive, trailing blanks allowed) as its #rrggbb, black and white kept as names (the themes restyle them); or # or 0x and 1 to 8 hexadecimal digits, read as gnuplot does as the number 0xAARRGGBB (#0f0 is 0x0000f0): #rrggbb, or with an alpha A (0 opaque, 255 transparent) #rrggbbaa, aa = 255 - A.

Attributes: pure

fortran
subroutine gnuplot_color(spec, color, ok)

Arguments

NameTypeIntentAttributesDescription
speccharacter(len=*)ingnuplot color.
colorcharacter(len=:)outallocatableSVG color, empty if not a color.
oklogicaloutA color.

Call graph

palette_words ​

Update palette from gnuplot set palette words: none (the default), rgbformulae R , G , B (rgb), defined (v c, ...), cubehelix [start S] [cycles C] [saturation S], gray/grey, color, positive, negative, maxcolors N, model RGB, and a palette name of foresight_colormaps (viridis, batlow, ..., case-insensitive); bad is the first word not understood.

fortran
subroutine palette_words(words, palette, bad)

Arguments

NameTypeIntentAttributesDescription
wordscharacter(len=*)inWords, blank separated (a defined list one word).
palettetype(palette_object)inoutPalette.
badcharacter(len=:)outallocatableFirst word not understood, empty if none.

Call graph

palette_gradient ​

Make palette the gradient of colors (RGB 0..1, clipped) at positions, increasing (equal ones make a sharp step), mapped to 0..1, as gnuplot defined and file palettes; bad says why not, empty if done.

Attributes: pure

fortran
subroutine palette_gradient(palette, positions, colors, bad)

Arguments

NameTypeIntentAttributesDescription
palettetype(palette_object)inoutPalette.
positionsreal(kind=R8P)inPositions.
colorsreal(kind=R8P)inColors (RGB, position).
badcharacter(len=:)outallocatableProblem, empty if none.

Call graph

Functions ​

is_default ​

Whether the palette has gnuplot's default colors: rgbformulae 7,5,15, positive (quantized or not).

Attributes: elemental

Returns: logical

fortran
function is_default(self) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(palette_object)inPalette.

Call graph

rgb ​

Color of the gray level gray (clamped to 0..1), 8-bit channels (rgb1 rounded).

Attributes: pure

Returns: integer(kind=I4P)

fortran
function rgb(self, gray) result(c)

Arguments

NameTypeIntentAttributesDescription
selfclass(palette_object)inPalette.
grayreal(kind=R8P)inGray level.

Call graph

rgb1 ​

Color of the gray level gray (clamped to 0..1), channels from 0 to 1 (gnuplot's rgb1_from_gray).

Attributes: pure

Returns: real(kind=R8P)

fortran
function rgb1(self, gray) result(f)

Arguments

NameTypeIntentAttributesDescription
selfclass(palette_object)inPalette.
grayreal(kind=R8P)inGray level.

Call graph

hsv_rgb ​

Red, green, blue (0..1) of hsv, hue 0..1 (not degrees), as gnuplot's HSV_2_RGB.

Attributes: pure

Returns: real(kind=R8P)

fortran
function hsv_rgb(hsv) result(f)

Arguments

NameTypeIntentAttributesDescription
hsvreal(kind=R8P)inHue, saturation, value.

Call graph

hex_color ​

#rrggbb of the 8-bit channels c.

Attributes: pure

Returns: character(len=7)

fortran
function hex_color(c) result(hex)

Arguments

NameTypeIntentAttributesDescription
cinteger(kind=I4P)inRed, green, blue.

Call graph

color_index ​

Index of gnuplot's color name (trailing blanks allowed), 0 if none: an exact match, else the first name of the table that begins name, as gnuplot's lookup_table_nth (grey75 is grey).

Attributes: pure

Returns: integer(kind=I4P)

fortran
function color_index(name) result(k)

Arguments

NameTypeIntentAttributesDescription
namecharacter(len=*)inColor name.

Call graph

hex_channels ​

Channels of rrggbb (0..255, as reals).

Attributes: pure

Returns: real(kind=R8P)

fortran
function hex_channels(hex) result(c)

Arguments

NameTypeIntentAttributesDescription
hexcharacter(len=6)inHexadecimal color.

Call graph

formula ​

gnuplot rgbformula n (-36..36, negative for the formula of 1 - x) at x, clamped to 0..1.

Attributes: pure

Returns: real(kind=R8P)

fortran
function formula(n, x) result(f)

Arguments

NameTypeIntentAttributesDescription
ninteger(kind=I4P)inFormula number.
xreal(kind=R8P)inGray level.

Call graph

abbreviates ​

Whether word is full or an abbreviation of it of shortest characters at least (gnuplot's almost_equals).

Attributes: pure

Returns: logical

fortran
function abbreviates(word, full, shortest) result(yes)

Arguments

NameTypeIntentAttributesDescription
wordcharacter(len=*)inWord read.
fullcharacter(len=*)inFull keyword.
shortestintegerinShortest abbreviation.

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.