Documentation

配色栏

配色栏showing color scale

Syntax

配色栏
配色栏(target)
配色栏('peer',target)
配色栏(___,lcn)
配色栏(___,名称,值)
c =配色键(___)
配色栏('off')
配色栏(target,'off')
配色栏(c,'off')

描述

example

配色栏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.

example

配色栏(___,lcn)在指定的位置中显示合格栏lcn, such as'northoutside'。Specifylcnas the last argument in any of the previous syntaxes. Not all types of charts support modifying the colorbar location.

example

配色栏(___,Name,Value)使用一个或多个名称值对参数修改配色栏外观。例如,'方向','reverse'reverses the color scale. SpecifyName,Valueas the last pair of arguments in any of the previous syntaxes. Not all types of charts support modifying the colorbar appearance.

example

c= colorbar(___)returns the配色栏目的。您可以在创建配色栏后使用此对象设置属性。指定返回参数c使用任何先前的语法。

example

配色栏('离开')deletes colorbars associated with the current axes or chart.

配色栏(目标,'离开')deletes colorbars associated with the axes or chart specified by目标

配色栏(c,'离开')deletes the colorbar specified byc

例子

collapse all

添加一个colorbar表面巴解组织t indicating the color scale.

figure surf(peaks) colorbar

默认情况下,配色栏function adds a vertical colorbar to the right side of the graph.

Add a horizontal colorbar below a plot by specifying the colorbar location as'southoutside'

figure contourf(peaks) colorbar('southoutside')

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 the colorbar tick marks and tick labels on the side of a colorbar facing the surface plot.

surf(peaks) colorbar('AxisLocation','in')

创建一个带有两个子图的图。将配色栏添加到两个子图中。

figure subplot(2,1,1)% upper subplotsurf(peaks) colorbar subplot(2,1,2)% lower subplotcontourf(peaks) colorbar

将配色栏添加到绘图中,并指定配色栏tick标记和刻度标签。指定与刻度标记相同数量的刻度标签。如果您没有指定足够的tick标签,则配色栏function repeats the labels.

轮廓(峰)配色杆('ticks',[-5,-2,1,4,7],。。。'ticklabels',{'寒冷的','Cool','Neutral','Warm',“热”})

Add a text label along a colorbar.

冲浪(峰)C =配色杆;C.Label.String =“高程(1000年代英尺)”;

添加一个colorbar表面巴解组织t.

figure surf(peaks) colorbar

从表面图中删除配色栏。

配色栏('离开')

Input Arguments

collapse all

配色栏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')

配色栏的目标,指定为对象,PolarAxesobject, or a graphics object that has a配色栏Visibleproperty. 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

collapse all

相对于轴的位置,指定为该表中列出的值之一。

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 byPositionproperty Vertical

To display the colorbar in a location that does not appear in the table, use thePosition属性以指定自定义位置。如果您设置Positionproperty, then MATLAB®sets the地点property to'manual'。当相关轴无法调整大小以适应配色栏时地点property is set to'manual'

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'}

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 theTickLabelInterpreterproperty 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} Setspeciferas 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'

该表列出了支持的特殊字符金宝appInterpreterproperty set to'Tex'

Character Sequence Symbol Character Sequence Symbol Character Sequence Symbol

α

\upsilon

\sim

~

\角度

\ phi

\leq

\ast

*

\chi

χ

\infty

\beta

β

\psi

ψ

\clubsuit

\gamma

γ

\ omega

ω

\diamondsuit

\delta

δ

\Gamma

γ

\heartsuit

\ Epsilon

ϵ

\Delta

δ

\ spadesuit

\zeta

ζ

\Theta

θ

\leftrightarrow

\ eta

η

\Lambda

λ

\leftarrow

\theta

θ

\Xi

ξ

\Leftarrow

\vartheta

ϑ

\ pi

π

\uparrow

\iota

\ sigma

σ

\右箭头

\kappa

κ

\Upsilon

ϒ

\Rightarrow

\ lambda

λ

\ phi

φ

\ downarrow

\亩

µ

\Psi

ψ

\circ

º

\ nu

ν

\欧米茄

ω

\下午

±

\xi

ξ

\forall

\geq

\ pi

π

\exists

\propto

\ rho

ρ

\你

\partial

\sigma

σ

\cong

\bullet

\varsigma

ς

\approx

\div

÷

\tau

τ

\关于

\ neq

\ equiv

\ oplus

\aleph

\Im

\cup

\wp

\ otimes

\ subseteq

\ oslash

\cap

\in

\ supseteq

\ supset

\ lceil

\subset

\int

\cdot

·

\ o

O

\rfloor

\ neg

¬

\nabla

\lfloor

\次

x

\ldots

。。。

\perp

\ surd

\prime

´

\wedge

\ varpi

ϖ

\ 0

\ rceil

\rangle

\mid

|

\vee

\ langle

\版权

©

LaTeX Markup

要使用乳胶标记,请设置TickLabelInterpreterproperty to'latex'。显示的文本使用默认的乳胶字体样式。这FontName,FontWeight, andFontAngleproperties 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/

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, 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.

字体大小,指定为标量值大于点单元中的零。默认字体大小取决于特定的操作系统和语言环境。

If you change the axes font size, then MATLAB automatically sets the font size of the配色栏对象为轴字体大小的90%。如果您手动设置配色栏对象字体大小,然后更改轴字体大小不会影响配色栏目的。

Output Arguments

collapse all

配色栏目的。采用cto set properties of the colorbar after it is created.

More About

collapse all

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 theLabelproperty 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')删除当前轴中的所有配色栏。所有这些命令都是等效的。

Introduced before R2006a

Was this topic helpful?