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; 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.

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_VIRIDISinteger(kind=I4P)parameterviridis.
VIRIDIScharacter(len=*)parameterviridis, 256 colors as rrggbb (gnuplot 6.0 set palette viridis).

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.
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.

Subroutines ​

named_color ​

Channels of a color: #rrggbb or one of gnuplot's names (black, white, red, green, blue, yellow, cyan, magenta, gray, grey, orange, purple, dark-green, dark-blue, brown, violet, navy).

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

palette_words ​

Update palette from gnuplot set palette words: none (the default), rgbformulae R , G , B (rgb), defined (v c, ...), gray/grey, color, viridis, positive, negative, maxcolors N, model RGB; 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

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.

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

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.

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