Colors in Matlab

From biophysics
Revision as of 10:52, 24 September 2024 by Lof (talk | contribs) (→‎Color maps)
Jump to navigation Jump to search

RGB colors

For coding purposes colors are mostly specified in RGB, which stands for Red, Blue and Green. The values range from 0 to 1. As an example: the color red is given by the triple [1,0,0]. Since it is hard to know what a certain triple (e.g. [0.5, 1, 0.5]) stands for it is more easy to call them by their name.

We have created a few functions for RGB colors by their names:

  • <RGBcolors> for english names
  • <RGBkleuren> for dutch names
  • <RGBfarben> for german names
  • <RGBcolores> for spanish names

A few examples:

>>colores.AZUL_CLARO
ans = 0.5000   0.5000   1.0000

>>kleuren.FELROZE
ans = 0.5000   0.5000   1.0000

>>farben.BLAU
ans = 0.0000   0.0000   1.0000

>>colors.LIME
ans = 0.0000   1.0000   0.0000

All the named colors are:

RGB Code Hex Code English Name Nederlandse Naam Deutsche Name Nombre en Español Kleur
[0.00, 1.00, 0.00] #00FF00 Lime Limoen Limettengrün Lima
[1.00, 0.00, 0.00] #FF0000 Red Rood Rot Rojo
[0.00, 0.00, 1.00] #0000FF Blue Blauw Blau Azul
[0.00, 1.00, 1.00] #00FFFF Cyan Cyaan Cyan Cian
[1.00, 0.00, 1.00] #FF00FF Magenta Magenta Magenta Magenta
[1.00, 1.00, 0.00] #FFFF00 Yellow Geel Gelb Amarillo
[0.00, 0.00, 0.00] #000000 Black Zwart Schwarz Negro
[0.50, 0.50, 0.50] #808080 Grey Grijs Grau Gris
[1.00, 1.00, 1.00] #FFFFFF White Wit Weiß Blanco
[0.50, 0.00, 0.00] #800000 Maroon Kastanjebruin Kastanienbraun Granate
[0.00, 0.50, 0.00] #008000 Green Groen Grün Verde
[0.00, 0.00, 0.50] #000080 Navy Blue Marineblauw Marineblau Azul Marino
[0.00, 0.50, 0.50] #008080 Olive Olijf Olive Oliva
[0.50, 0.00, 0.50] #800080 Purple Paars Lila Morado
[0.50, 0.50, 0.00] #808000 Teal Zeegroen Türkis Verde azulado
[0.50, 0.00, 1.00] #8000FF Indigo Indigo Indigo Índigo
[0.50, 1.00, 0.00] #80FF00 Chartreuse Chartreuse Chartreuse Chartreuse
[0.00, 0.50, 1.00] #0080FF Royal Blue Koningsblauw Königsblau Azul Real
[1.00, 0.00, 0.50] #FF0080 Hot Pink Felroze Knallrosa Rosa Brilliante
[1.00, 0.50, 0.00] #FF8000 Orange Oranje Orange Naranja
[0.00, 1.00, 0.50] #00FF80 Spring Green Lentegroen Frühlingsgrün Verde Primavera
[0.50, 0.50, 1.00] #8080FF Light Blue Lichtblauw Hellblau Azul Claro
[0.50, 1.00, 0.50] #80FF80 Light Green Lichtgroen Hellgrün Verde Claro
[1.00, 0.50, 0.50] #FF8080 Salmon Zalmroze Lachs Salmón
[0.50, 1.00, 1.00] #80FFFF Aquamarine Aquamarijn Aquamarin Aguamarina
[1.00, 0.50, 1.00] #FF80FF Orchid Orchidee Orchidee Orquídea
[1.00, 1.00, 0.50] #FFFF80 Light Yellow Lichtgeel Hellgelb Amarillo Claro

Color maps

You can make a color map for plots like surface plots:

map = [RGBcolors.LIME, RGBcolors.BLUE, RGBcolors.MAGENTA];
colormap(map);
surf(peaks);
Name Description
parula A smooth, perceptually uniform colormap with blue-to-yellow transitions, default in MATLAB since version R2014b.
turbo A vibrant, perceptually uniform colormap with a wide dynamic range, transitioning from blue to red via green and yellow.
hsv A circular colormap representing the hue component in the HSV color space, cycling through the full range of colors.
hot A colormap with transitions from black to red, then yellow, and finally white, typically used for thermal or intensity data.
cool A simple linear colormap that transitions smoothly from cyan to magenta, often used for contrast with warm color schemes.
spring A pastel colormap transitioning from magenta to yellow, often used to represent seasonal or thematic data.
summer A light green to yellow colormap that gives a warm, sunny feel, used for representing continuous data.
autumn A colormap with warm tones transitioning from red to yellow, evoking the colors of autumn leaves.
winter A cool colormap transitioning from blue to green, commonly used to represent water or icy conditions.
gray A simple grayscale colormap, transitioning linearly from black to white, often used in intensity maps.
bone A colormap with a grayscale base, but with a slight blue tint, designed for displaying images of bones and x-rays.
copper A colormap transitioning from black to copper-brown, useful for visualizing data with metallic or heat-related themes.
pink A pastel colormap with a gradient from dark to light pink, often used for softer data visualizations.
lines A colormap with distinct, evenly spaced colors, designed for line plots with many different lines.
jet A rainbow colormap transitioning from blue to red, previously the default in MATLAB, but criticized for non-uniform perceptual changes.
colorcube A discrete colormap that uses a fixed set of distinct colors, typically used for categorical or label-based data.
prism A repeating sequence of vivid colors, often used for periodic or cyclic data.
flag An alternating red, white, blue, and black colormap, often used for data with binary or oscillating patterns.