lcolorbar
Color bar with text labels
Description
lcolorbar(
displays a vertical color
bar, with labels specified by the text in labels
)labels
, to the right of the
current axes.
lcolorbar(
specifies options for the color bar using name-value arguments.labels
,Name,Value
)
Examples
Create Labeled Color Bar
Import elevation data for a region surrounding South Boulder Peak in Colorado. Calculate the viewshed for a sample point 1000
meters above the terrain.
[Z,R] = readgeoraster("n39_w106_3arc_v2.dt1","OutputType","double"); [vis,visR] = viewshed(Z,R,39.6,-105.6,1000);
Display the viewshed on a map, using green for visible areas and purple for obscured areas.
figure usamap(vis,visR) geoshow(vis,visR,"DisplayType","surface") cmap = [0.4940 0.1840 0.5560; 0.4660 0.6740 0.1880];
Add a labeled color bar. Avoid truncating the text by moving the color bar to the left.
colormap(cmap) h = lcolorbar(["Obscured" "Visible"]); h.Position(1) = h.Position(1)-0.1;
Input Arguments
labels
— Tick mark labels
cell array of character vectors | string array
Tick mark labels, specified as a cell array of character vectors or a string array.
The number of elements in labels
must match the length of the
colormap.
Example: ["blue" "green" "yellow"]
Data Types: cell
| char
| string
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: lcolorbar(labels,Location="horizontal")
displays a horizontal
color bar below the axes.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: lcolorbar(labels,"Location","horizontal")
displays a
horizontal color bar below the axes.
Note
In addition to the name-value arguments in this section, you can use name-value
arguments to specify values for the properties of the Axes
object
returned by this function. For more information about the properties of
Axes
objects, see Axes Properties.
Location
— Location of color bar with respect to axes
"vertical"
(default) | "horizontal"
Location of the color bar with respect to the axes, specified as one of these options:
"vertical"
— Display the color bar vertically and to the right of the axes."horizontal"
— Display the color bar horizontally and below the axes.
Data Types: char
| string
TitleString
— Title of color bar
character vector | string scalar
Title of the color bar, specified as a character vector or string scalar.
Data Types: char
| string
XLabelString
— x-label of color bar
character vector | string scalar
x-label of the color bar, specified as a character vector or string scalar.
Data Types: char
| string
YLabelString
— y-label of color bar
character vector | string scalar
y-label of the color bar, specified as a character vector or string scalar.
Data Types: char
| string
ZLabelString
— z-label of color bar
character vector | string scalar
z-label of the color bar, specified as a character vector or string scalar.
Data Types: char
| string
ColorAlignment
— Alignment of labels in color bar
"center"
(default) | "ends"
Alignment of the labels in the color bar, specified as one of these options:
"center"
— Center the labels on the color bands."ends"
— Center the labels on the color breaks.
Data Types: char
| string
Output Arguments
h
— Output color bar
Axes
object
Output color bar, returned as an Axes
object.
Version History
Introduced before R2006a
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)