Syntax
cm=color(c)
Input Parameter
c : | | color" r y m c g b w k' |
Output Parameter
cm : | | index to colormap VLcol |
Examples
Set colormap for green
color('y')
colormap (color('g'));
caxis ([0 7]);
Copyright 2012-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, named color
, is designed to generate a color index from a given color character. It is part of the SG-Library and was created by Tim Lueth in 2012.
Input Parameters
- c: A character representing a color. The accepted characters are 'r', 'y', 'm', 'c', 'g', 'b', 'w', and 'k'.
Output Results
- cm: An index corresponding to the colormap VLcol.
Algorithm Steps
- Define a string
cmap
containing the characters 'k', 'b', 'g', 'c', 'r', 'm', 'y'.
- Check if the input
c
is numeric. If it is, set cm
to c
and return.
- Use a
switch
statement to determine the index cm
based on the input character c
:
- Case 'w': Set
cm
to 7.
- Case 'y': Set
cm
to 6.
- Case 'm': Set
cm
to 5.
- Case 'r': Set
cm
to 4.
- Case 'c': Set
cm
to 3.
- Case 'g': Set
cm
to 2.
- Case 'b': Set
cm
to 1.
- Case 'k': Set
cm
to 0.
- Otherwise: Set
cm
to 7.
- If there are no output arguments (
nargout==0
), perform the following visualization steps:
- Call
SGfigure
with parameters -30 and 30.
- Create a bar object
A
using SGbar
.
- Apply the color index
cm
to the bar object using SGcolorfaces
.
- Plot the object with transparency using
SGplotalpha
.
Algorithm explaination created using ChatGPT on 2025-08-18 23:29. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21