配色栏
配色栏showing color scale
Syntax
配色栏
配色栏(target)
配色栏('peer',target)
配色栏(___,lcn)
配色栏(___,名称,值)
c =配色键(___)
配色栏('off')
配色栏(target,'off')
配色栏(c,'off')
描述
配色栏
displays a vertical colorbar to the right of the current axes or chart. Colorbars display the current colormap and indicate the mapping of data values into the colormap.
配色栏(
将配色栏添加到轴或图表目标
)目标
。
配色栏(
adds a colorbar to the axes specified by'同伴'
,目标
)目标
。This syntax is not recommended and might be removed in a future release. Use配色栏(target)
instead.
配色栏(___,
在指定的位置中显示合格栏lcn
)lcn
, such as'northoutside'
。Specifylcn
as the last argument in any of the previous syntaxes. Not all types of charts support modifying the colorbar location.
配色栏(___,
使用一个或多个名称值对参数修改配色栏外观。例如,Name,Value
)'方向','reverse'
reverses the color scale. SpecifyName,Value
as the last pair of arguments in any of the previous syntaxes. Not all types of charts support modifying the colorbar appearance.
例子
将配色栏添加到图
添加一个colorbar表面巴解组织t indicating the color scale.
figure surf(peaks) colorbar
默认情况下,配色栏
function adds a vertical colorbar to the right side of the graph.
Add Horizontal Colorbar to Graph
Add a horizontal colorbar below a plot by specifying the colorbar location as'southoutside'
。
figure contourf(peaks) colorbar('southoutside')
Reverse Colorbar Direction
Reverse the direction of values in a colorbar on a graph by setting the'方向'
property of the colorbar to“反向”
。
figure surf(peaks) colorbar('方向',“反向”)
这配色栏values ascend from top to bottom instead of ascending from bottom to top.
Display Colorbar Ticks on Opposite Side
Display the colorbar tick marks and tick labels on the side of a colorbar facing the surface plot.
surf(peaks) colorbar('AxisLocation','in')
Add Colorbars to Subplots
创建一个带有两个子图的图。将配色栏添加到两个子图中。
figure subplot(2,1,1)% upper subplotsurf(peaks) colorbar subplot(2,1,2)% lower subplotcontourf(peaks) colorbar
指定Colorbar Tick和Tick标签
将配色栏添加到绘图中,并指定配色栏tick标记和刻度标签。指定与刻度标记相同数量的刻度标签。如果您没有指定足够的tick标签,则配色栏
function repeats the labels.
轮廓(峰)配色杆('ticks',[-5,-2,1,4,7],。。。'ticklabels',{'寒冷的','Cool','Neutral','Warm',“热”})
Label Colorbar
Delete Colorbar
Input Arguments
lcn
—配色栏location and orientation
'eastoutside'
(default) |'北'
|'南'
|'east'
|'west'
|'northoutside'
|。。。
配色栏location and orientation with respect to the axes, specified as one of the values in this table.
Value | 结果位置 | Resulting Orientation |
---|---|---|
'北' |
轴的顶部 | Horizontal |
'南' |
Bottom of axes | Horizontal |
'east' |
轴的右侧 | Vertical |
'west' |
Left side of axes | Vertical |
'northoutside' |
Top outside of axes | Horizontal |
'southoutside' |
底部的底部 | Horizontal |
'eastoutside' |
Right outside of axes (default) | Vertical |
'Westoutside' |
Left outside of axes | Vertical |
If a colorbar already exists in the specified location, then an updated colorbar replaces the existing one. To ensure that the colorbar does not overlap the graph, specify a location with the suffix,外部
。
您还可以使用其配色栏位置地点
property. For example,配色栏(“位置”,“ Northoutside”)
is the same as配色栏('northoutside')
。
例子:配色栏('westoutside')
目标
—Target for colorbar
轴
object|PolarAxes
object|graphics object
配色栏的目标,指定为轴
对象,PolarAxes
object, or a graphics object that has a配色栏Visible
property. For example, you can add or remove a colorbar from aHeatmapChart
目的。
If you do not specify the target, then the配色栏
command affects the current axes (the object returned byGCA
).
Note
有些图表不支持修改配色栏外观,例如位置金宝app或返回配色栏
object as an output argument.
Name-Value Pair Arguments
配色栏('FontSize',12,'Direction','reverse')
sets the font size of the colorbar to 12 points and reverses the orientation of the colorbar.
这配色栏properties listed here are only a subset. For a complete list see配色栏Properties。
'Location'
—相对于轴的位置
'eastoutside'
(default) |'北'
|'南'
|'east'
|'west'
|'northoutside'
|。。。
相对于轴的位置,指定为该表中列出的值之一。
Value | 结果位置 | Resulting Orientation |
---|---|---|
'北' |
轴的顶部 | Horizontal |
'南' |
Bottom of axes | Horizontal |
'east' |
轴的右侧 | Vertical |
'west' |
Left side of axes | Vertical |
'northoutside' |
Top outside of axes | Horizontal |
'southoutside' |
底部的底部 | Horizontal |
'eastoutside' |
Right outside of axes (default) | Vertical |
'Westoutside' |
Left outside of axes | Vertical |
'manual' |
Determined byPosition property |
Vertical |
To display the colorbar in a location that does not appear in the table, use thePosition
属性以指定自定义位置。如果您设置Position
property, then MATLAB®sets the地点
property to'manual'
。当相关轴无法调整大小以适应配色栏时地点
property is set to'manual'
。
'ticklabels'
—Tick mark labels
cell array of character vectors|string array|numeric array|角色向量|string
Tick mark labels, specified as a cell array of character vectors, a string array, a numeric array, a character vector, or a string. By default, the colorbar labels the tick marks with numeric values. If you specify labels and do not specify enough labels for all the tick marks, then MATLAB cycles through the labels.
例子:{'冷','温暖','hot'}
'TickLabelInterpreter'
—Interpretation of characters in tick labels
'Tex'
(default) |'latex'
|'none'
tick标签字符的解释,指定为以下值之一:
'Tex'
— Interpret labels using a subset of the TeX markup.'latex'
— Interpret labels using a subset of LaTeX markup.'none'
- 显示字面字符
TeX Markup
By default, MATLAB supports a subset of TeX markup. Use TeX markup to add superscripts and subscripts, modify the text type and color, and include special characters in the labels.
This table lists the supported modifiers when theTickLabelInterpreter
property is set to'Tex'
, which is the default value. Most modifiers remain in effect until the end of the text. Superscripts and subscripts modify only the next character or the text within the curly braces{}
。
Modifier | 描述 | Example |
---|---|---|
^{ } |
Superscript | 'text^{superscript}' |
_{ } |
Subscript | 'text_{subscript}' |
\bf |
Bold font | '\bf text' |
\it |
Italic font | '\it text' |
\ sl |
倾斜字体(很少可用) | '\sl text' |
\R M |
正常字体 | '\ rm文本' |
\ fontname {specifier} |
Set说明符 as the name of a font family to change the font style. You can use this in combination with other modifiers. |
'\fontname{Courier} text' |
\fontsize{specifier} |
Set说明符 as a scalar numeric value to change the font size. |
'\fontsize{15} text' |
\color{specifier} |
Setspecifer as one of these colors:red ,green ,yellow ,magenta ,blue ,black ,white ,gray ,darkGreen ,orange , orlightBlue 。 |
'\color{magenta} text' |
\color[rgb]{specifier} |
Set说明符 as a three-element RGB triplet to change the font color. |
'\color[rgb]{0,0.5,0.5} text' |
该表列出了支持的特殊字符金宝appInterpreter
property set to'Tex'
。
Character Sequence | Symbol | Character Sequence | Symbol | Character Sequence | Symbol |
---|---|---|---|---|---|
|
α |
|
见 |
|
~ |
|
∠ |
|
|
≤ |
|
|
|
|
χ |
|
∞ |
|
β |
|
ψ |
|
♣ |
|
γ |
|
ω |
|
♦ |
|
δ |
|
γ |
|
♥ |
|
ϵ |
|
δ |
|
♠ |
|
ζ |
|
θ |
|
↔ |
|
η |
|
λ |
|
← |
|
θ |
|
ξ |
|
⇐ |
|
ϑ |
|
π |
|
↑ |
|
我 |
|
σ |
|
→ |
|
κ |
|
ϒ |
|
⇒ |
|
λ |
|
φ |
|
↓ |
|
µ |
|
ψ |
|
º |
|
ν |
|
ω |
|
± |
|
ξ |
|
∀ |
|
≥ |
|
π |
|
∃ |
|
∝ |
|
ρ |
|
∍ |
|
∂ |
|
σ |
|
≅ |
|
• |
|
ς |
|
≈ |
|
÷ |
|
τ |
|
ℜ |
|
≠ |
|
≡ |
|
⊕ |
|
ℵ |
|
ℑ |
|
∪ |
|
℘ |
|
⊗ |
|
⊆ |
|
∅ |
|
∩ |
|
∈ |
|
⊇ |
|
⊃ |
|
⌈ |
|
⊂ |
|
∫ |
|
· |
|
O |
|
⌋ |
|
¬ |
|
∇ |
|
⌊ |
|
x |
|
。。。 |
|
⊥ |
|
√ |
|
´ |
|
∧ |
|
ϖ |
|
∅ |
|
⌉ |
|
〉 |
|
| |
|
∨ |
|
〈 |
|
© |
LaTeX Markup
要使用乳胶标记,请设置TickLabelInterpreter
property to'latex'
。显示的文本使用默认的乳胶字体样式。这FontName
,FontWeight
, andFontAngle
properties do not have an effect. To change the font style, use LaTeX markup within the text.
这maximum size of the text that you can use with the LaTeX interpreter is 1200 characters. For multiline text, the maximum size of the text reduces by about 10 characters per line.
For more information about the LaTeX system, see The LaTeX Project Web site athttp://www.latex-project.org/。
'ticks'
—Tick mark locations
vector of monotonically increasing numeric values
Tick mark locations, specified as a vector of monotonically increasing numeric values. The values do not need to be equally spaced. If you do not want tick marks displayed, then set the property to the empty vector,[]
。
例子:[-1,0,1,2,3,4,5]
数据类型:single
|双倍的
'方向'
—Direction of color scale
“正常”
(default) |“反向”
Direction of color scale, specified as one of these values:
“正常”
- 显示colormap和标签从底部到顶部升至垂直配色栏,从左到右升至水平配色杆。“反向”
— Display the colormap and labels descending from bottom to top for a vertical colorbar, and descending from left to right for a horizontal colorbar.
'字体大小'
—Font size
标量值大于零
字体大小,指定为标量值大于点单元中的零。默认字体大小取决于特定的操作系统和语言环境。
If you change the axes font size, then MATLAB automatically sets the font size of the配色栏
对象为轴字体大小的90%。如果您手动设置配色栏
对象字体大小,然后更改轴字体大小不会影响配色栏
目的。
Output Arguments
c
—配色栏
object
配色栏
object
配色栏
目的。采用c
to set properties of the colorbar after it is created.
More About
Compatibility Considerations
Starting in R2014b, the配色栏
function returns a配色栏
目的。In previous releases it returns an轴
目的。
尖端
To add a text description along the colorbar, access the underlying text object using the
Label
property of the colorbar.C.Label.String ='My Colorbar Label';
To change the label appearance, such as the font style or color, set other text properties. For a list of properties, seeText Properties。例如,this code changes the font size.
c.Label.FontSize = 12;
Adding a colorbar might resize the axes to accommodate the colorbar.
If an axes does not exist, then the
配色栏
function creates a blank axes and displays a colorbar with the default colormap.You can use
配色栏('delete')
or配色栏(“隐藏”)
instead of配色栏('off')
删除当前轴中的所有配色栏。所有这些命令都是等效的。
See Also
Functions
Properties
Introduced before R2006a
matlab命令
You clicked a link that corresponds to this MATLAB command:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。金宝app
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éricaLatina(Español)
- Canada(英语)
- United States(英语)
Europe
- 比利时(英语)
- 丹麦(英语)
- Deutschland(Deutsch)
- España(Español)
- Finland(英语)
- France(Français)
- Ireland(英语)
- 意大利(Italiano)
- Luxembourg(英语)
- Netherlands(英语)
- Norway(英语)
- Österreich(Deutsch)
- Portugal(英语)
- Sweden(英语)
- 瑞士
- 英国(英语)