fliplightness
Description
Examples
Plot a dark blue line in a light-themed figure.
f = figure(Theme="light"); p = plot([0 3 1 6 4],LineWidth=2,Color="#0023ED");
Change the theme of the figure to "dark"
.
f.Theme="dark";
Lighten the color of the line.
newcolor = fliplightness("#0023ED");
p.Color = newcolor;
You can change the color palette of a plot by calling the colororder
function. Then you can use the fliplightness
function to update the colors for dark theme.
Plot seven lines in a light-themed figure. Use the "dye"
color palette by calling the colororder
function. Returning the palette as matrix C
, which is a 7-by-3 matrix of RGB triplets.
f = figure(Theme="light"); ax = axes; y = [6 5 4 3 2 1 0; 7 6 5 4 3 2 1]; plot(y,LineWidth=2) C = colororder(ax,"dye");
Change the theme of the figure to "dark"
. Some of the lines are slightly less visible against the black background of the figure.
f.Theme ="dark";
Lighten the dark colors of C
(rows 1, 3, 4, and 6), and then call the colororder
function again to update the colors of the lines.
toodark = [1 3 4 6]; C(toodark,:) = fliplightness(C(toodark,:)); colororder(ax,C)
Input Arguments
Colors to lighten or darken, specified as a matrix of RGB triplets, a truecolor image, or an array of hexadecimal color codes or color names.
RGB triplet — A three-element row vector whose elements specify the intensities of the red, green, and blue components of a color. For m colors, specify an m-by-3 matrix. The intensities must within the range supported by the data type. For
double
andsingle
values, the range is [0, 1]. For unsigned 8-bit integer values, the range is [0, 255].Truecolor image — An m-by-n-by-3 array of color pixel values. The color of each pixel is determined by the combination of the red, green, and blue intensities stored in each color plane at the pixel's location. For example, the red, green, and blue color components of the pixel (10, 5) in an RGB image
X
are stored inX(10,5,1)
,X(10,5,2)
, andX(10,5,3)
, respectively.Hexadecimal color code — A string scalar or character vector that starts with a hash symbol (
#
) followed by three or six hexadecimal digits, which can range from0
toF
. The values are not case sensitive. Therefore, the color codes"#FF8800"
,"#ff8800"
,"#F80"
, and"#f80"
are equivalent. To specify multiple hexadecimal color codes, use a string array or a cell array of character vectors.
Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.
Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" | |
"green" | "g" | [0 1 0] | "#00FF00" | |
"blue" | "b" | [0 0 1] | "#0000FF" | |
"cyan"
| "c" | [0 1 1] | "#00FFFF" | |
"magenta" | "m" | [1 0 1] | "#FF00FF" | |
"yellow" | "y" | [1 1 0] | "#FFFF00" | |
"black" | "k" | [0 0 0] | "#000000" | |
"white" | "w" | [1 1 1] | "#FFFFFF" |
Example: fliplightness([0 0 1])
Example: fliplightness([0 0 1; 0 0 0.5])
Example: fliplightness(["#FF0076","#0000FF"])
Example: fliplightness(["blue","black"])
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
Lightness-adjusted colors, returned as a matrix of RGB triplets, a truecolor image,
or an array of hexadecimal color codes that has the same size, shape, and data type as
the input colors. If you specify a color name as input,
fliplightness
returns a matrix of RGB triplets.
Calling fliplightness
and passing the result to
fliplightness
a second time might not return the original color
value.
Algorithms
fliplightness
performs a color space conversion to access the
lightness information of a color. Then it adjusts the lightness without affecting the
hue.
Version History
Introduced in R2025a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)