## Display of the color scale of a color palette

### Description

The Display.palette function displays the color scale as it is used for representations in espadon functions

### Usage

display.palette(
col,
breaks = NULL,
factors = NULL,
override.breaks = FALSE,
bg = "black",
new.window = TRUE,
ylab = ""
)


### Arguments

 col Vector of colors like the ones generated by rainbow, heat.colors, etc. breaks Vector of breaks for the color palette. It is the usual option for images or dose, for instance. Its length must be one unit more than col length. factors Vector containing the labels associated to each col. It should be used for tissue identification or image segment labelling. Its length must be col length. override.breaks Boolean. When FALSE (by default) ordinates are set to breaks. when TRUE colors are uniformely displayed, and associated breaks set to the correct ordinates for the given colors. bg Color of the background, seen by transparency for palette having alpha channel. new.window Boolean. If TRUE, it opens a new window for displaying the palette. ylab character string. Label of ordinates.

### Value

Returns in a new device (if new.window = TRUE), or in the active graphics window (if new.window = FALSE), the palette color defined by col and breaks in priority, or by col and factors.

### Note

the breaks are not necessarily evenly spaced. In this case, the colour palette can be represented as the breaks are defined (default option) or by choosing a constant spacing for each colour and displaying the associated abscissa calculated from the breaks (override.breaks = TRUE).

### Examples

## Not run:
# simple example for breaks and factors

display.palette (c ("red", "green", "blue"), breaks = c(0, 1, 3, 7),
ylab = "a simple color palette")
display.palette (c ("red", "green", "blue"), breaks = c(0, 1, 3, 7),
override.breaks = TRUE)
display.palette (c ("red", "green", "blue"), factors = c ("red", "green", "blue"))
display.palette (c ("gray", "green", "blue"), factors = c (NA, 1, 2))

# for RVV palette, HU range must be [-1000, 1000]
display.palette (pal.RVV (255), breaks = seq (-1000, 1000, length.out=256))

# a palette for dose, for instance
display.palette (rainbow (255, start = 0, end = 4/6, rev = TRUE),
breaks = seq (0, 60, length.out = 256))

# black & white palette for CTs or MRs
display.palette (grey.colors (255, start = 0, end = 1),
breaks = seq (0, 60, length.out = 256))

# transparency affects colors depending on background (black in first exemple,
# white in the second one)
display.palette (rainbow (255, s = seq (1, 0, length.out = 255),
start = 0, end = 4/6,
alpha = seq (0.8, 0, length.out = 255), rev = TRUE),
breaks = seq (0, 60, length.out=256))
display.palette (rainbow (255, s = seq (1, 0, length.out = 255),
start = 0, end = 4/6,
alpha = seq (0.8, 0, length.out = 255), rev = TRUE),
breaks = seq (0, 60, length.out=256), bg = "white")

## End(Not run)
# colors contracted range using non uniform breaks in the plot window
display.palette (rainbow(255, s = seq(1, 0.8, length.out = 255),
start = 0, end = 4/6,
alpha = seq(0.8, 0.6, length.out = 255), rev = TRUE),
breaks = seq (0, 1, length.out = 256)^0.25 * 60, bg="grey",
new.window = FALSE)

# the same using breaks override
display.palette (rainbow(255, s = seq(1, 0.8, length.out = 255),
start = 0, end = 4/6,
alpha = seq(0.8, 0.6, length.out = 255), rev = TRUE),
breaks = seq (0, 1, length.out = 256)^0.25 * 60, bg="grey",
override.breaks = TRUE, new.window = FALSE)