# clabel

Contour labeling

## 📝 Syntax

* clabel(C,h)
* clabel(C,h,v)
* clabel(C)
* clabel(C,v)
* tl = clabel(...)
* clabel(...,Name,Value)

## 📥 Input argument

* C -

Contour matrix returned by contour, contourf, or contour3. If you pass a contour object h, you may pass \[] for C.

* h -

Contour object handle returned by contour / contourf / contour3. When provided, labeling uses information attached to the contour object (levels and contour matrix).

* v -

Vector of contour levels to label. When provided, only these levels receive labels.

## 📤 Output argument

* t -

Text objects created by clabel. The String properties contain the contour values displayed.

* tl -

Text and line objects created when upright markers are used (for clabel(C)-style usage).

## 📄 Description

The clabel function inserts labels into contour plots:

* Provide a contour matrix C and contour object h to label rotated text along contour lines.
* Provide only C to add upright labels and '+' markers at contour locations.
* Pass a vector of levels v to label only specific contour values.
* Use Name,Value pairs to control text appearance (a subset of Text properties, plus LabelSpacing).

## 💡 Examples

Label contour plot levels (basic).

```matlab

figure();
[x,y,z] = peaks;
[C,h] = contour(x,y,z);
clabel(C,h)

```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-05c36d959a8b699c487456235dfb064b0b54b49c%2Fclabel_1.svg?alt=media) Label specific contour levels.

```matlab

figure();
[x,y,z] = peaks;
[C,h] = contour(x,y,z);
v = [2,6];
clabel(C,h,v)

```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-4c8227da502559dde02d6dbd74e6116029de74fa%2Fclabel_2.svg?alt=media) Set contour label properties with Name,Value pairs.

```matlab

figure();
[x,y,z] = peaks;
[C,h] = contour(x,y,z);
clabel(C,h,'FontSize',15,'Color','red')

```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-b1324cc62bb19aa37a96a75a822652f9b53708a6%2Fclabel_3.svg?alt=media) Label using only the contour matrix (upright labels).

```matlab

figure();
[x,y,z] = peaks;
C = contour(x,y,z);
clabel(C)

```

![](https://160667757-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LdPvJ6mJve3gz5MU4d1%2Fuploads%2Fgit-blob-1079027fa55b39d343e0956511c53e896abb61ab%2Fclabel_4.svg?alt=media)

## 🔗 See also

[contour](https://nelson-9.gitbook.io/Nelson/markdown/en/graphics/contour), [contourf](https://github.com/Nelson-numerical-software/nelson-gitbook/blob/master/markdown/en/graphics/contourf.md), [contourc](https://github.com/Nelson-numerical-software/nelson-gitbook/blob/master/markdown/en/graphics/contourf.md).

## 🕔 History

| Version | 📄 Description  |
| ------- | --------------- |
| 1.15.0  | initial version |
