# stem

Plot discrete sequence data.

## 📝 Syntax

* stem(Y)
* stem(X, Y)
* stem(..., 'filled')
* stem(..., LineSpec)
* stem(..., propertyName, propertyValue)
* stem(ax, ...)
* go = stem(...)

## 📥 Input argument

* X - Locations to plot data values in Y.
* Y - Data sequence to display.
* LineSpec - Line style, marker and/or color: character vector or scalar string.
* propertyName - a scalar string or row vector character.
* propertyValue - a value.
* ax - Axes object.

## 📤 Output argument

* gr - group of graphics object.

## 📄 Description

A two-dimensionalstem plot is a way to visualize data by representing it as lines extending from a horizontal baseline along the x-axis.

At the end of each line, there is a circle (which is the default marker), and the vertical position of this circle corresponds to the value of the data it represents.

stem(Y) creates a stem plot by taking the data sequence Y and drawing stems that extend from regularly spaced and automatically determined points along the x-axis.

If Y is a matrix, the stem function plots all elements in a row against the same x-value.

stem(X, Y) creates a stem plot that shows howX relates to the columns of Y.

Both X andY can be vectors or matrices of the same size.

X can be either a row or a column vector, andY should be a matrix with the same number of rows as the length of X.

If you want to specify whether to fill the circle at the end of each stem, you can use stem(...,'fill').

Moreover, by usingstem(..., LineSpec), you can define the line style, marker symbol, and color for the stems and the top marker.

Refer to LineSpec for more details on how to customize the appearance of the stem plot.

## 💡 Examples

```matlab
f = figure();
x = 1:10;
y = 2*x;
h = stem (x, y, 'MarkerFaceColor', [1 0 1]);
title('stem plot modified with property/value pair');
```

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

```matlab
f =figure();
% Defining base line - X input vector ranging from 0 to 2*pi
X = 0 : pi/100 : 2*pi;
% Defining the Y input vector as function of X
Y = exp(-3*X/4) .* cos(2*X);
% Third, we use the 'stem' function to plot discrete values
stem(X,Y)
```

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

## 🔗 See also

[plot](https://nelson-9.gitbook.io/nelson/markdown/en/graphics/plot).

## 🕔 History

| Version | 📄 Description  |
| ------- | --------------- |
| 1.0.0   | initial version |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nelson-9.gitbook.io/nelson/markdown/en/graphics/stem.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
