# `plot`::`Listplot`

Finite lists of 2D points

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```plot::Listplot(`[y1, y2, …]`, <`x = xmin .. xmax`>, <`a = amin .. amax`>, `options`)
plot::Listplot(`A1`, <`x = xmin .. xmax`>, <`a = amin .. amax`>, `options`)
plot::Listplot(`[[x1, y1], [x2, y2], …]`, <`a = amin .. amax`>, `options`)
plot::Listplot(`A2`, <`a = amin .. amax`>, `options`)
```

## Description

`plot::Listplot` serves for visualizing discrete data values ```[y1, y2, …]```. If no range `x = `x_{min}` .. `x_{max}`` is specified, the data are plotted as the points ```[x1, y1]```, ```[x2, y2]``` etc. with equidistant x-values ```x1 = 1```, `x2 = 2` etc. If a range ```x = `x_{min}` .. `x_{max}```` is specified, equidistant x-values between `xmin` and `xmax` are used.

If the data are specified as a list of coordinate pairs ```[[x1, y1], [x2, y2], …]```, `plot::Listplot` generates plot points with these coordinates.

With the attribute `LinesVisible` = `TRUE`, each pair of consecutive data points is connected by a curve.

With `InterpolationStyle` = `Linear` (default), the points are connected by straight line segments.

With `InterpolationStyle` = `Cubic`, a cubic spline curve is used to connect the points. The spline curve between two data points is rendered as a collection of m + 1 straight line segments, where m is specified by the attribute `Submesh` = `m`.

Use `LinesVisible` = `FALSE`, if only the data points without connecting lines are to be rendered.

## Attributes

AttributePurposeDefault Value
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`AntiAliased`antialiased lines and points?`TRUE`
`Data`the (statistical) data to plot
`FillColorDirection`the direction of color transitions on surfaces[`0`, `0`]
`Frames`the number of frames in an animation`50`
`InterpolationStyle`interpolation via linear or cubic splines`Linear`
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`LineColor`color of lines`RGB::Blue`
`LineWidth`width of lines`0.35`
`LineColor2`color of lines`RGB::DeepPink`
`LineStyle`solid, dashed or dotted lines?`Solid`
`LinesVisible`visibility of lines`TRUE`
`LineColorType`line coloring types`Flat`
`LineColorFunction`functional line coloring
`LineColorDirection`the direction of color transitions on lines[`0`, `1`]
`LineColorDirectionX`x-component of the direction of color transitions on lines`0`
`LineColorDirectionY`y-component of the direction of color transitions on lines`1`
`LineColorDirectionZ`z-component of the direction of color transitions on lines`1`
`Name`the name of a plot object (for browser and legend)
`ParameterEnd`end value of the animation parameter
`ParameterName`name of the animation parameter
`ParameterBegin`initial value of the animation parameter
`ParameterRange`range of the animation parameter
`PointSize`the size of points`1.5`
`PointColor`the color of points`RGB::Black`
`PointStyle`the presentation style of points`FilledCircles`
`PointsVisible`visibility of mesh points`TRUE`
`Submesh`density of submesh (additional sample points)`6`
`TimeEnd`end time of the animation`10.0`
`TimeBegin`start time of the animation`0.0`
`TimeRange`the real time span of an animation`0.0` .. `10.0`
`Title`object title
`TitleFont`font of object titles[`" sans-serif "`, `11`]
`TitlePosition`position of object titles
`TitleAlignment`horizontal alignment of titles w.r.t. their coordinates`Center`
`TitlePositionX`position of object titles, x component
`TitlePositionY`position of object titles, y component
`Visible`visibility`TRUE`
`VisibleAfter`object visible after this time value
`VisibleBefore`object visible until this time value
`VisibleFromTo`object visible during this time range
`VisibleAfterEnd`object visible after its animation time ended?`TRUE`
`VisibleBeforeBegin`object visible before its animation time starts?`TRUE`
`XMax`final value of parameter “x”
`XMin`initial value of parameter “x”
`XName`name of parameter “x”
`XRange`range of parameter “x”
`XSubmesh`density of additional sample points for parameter “x”`6`

## Examples

### Example 1

We plot 5 discrete data values as points with equidistant x-values 1, 2, 3, 4, 5:

`plot(plot::Listplot([1, 0, 1, 0, 1]))` We plot two data samples and place them side by side by specifying suitable ranges for the horizontal variable:

```plot(plot::Listplot([1, 0, 2, 1], x = 0..1, Color = RGB::Red), plot::Listplot([0, 1, 0, 2], x = 1..2, Color = RGB::Blue))``` We specify x-coordinates for the data points:

```plot(plot::Listplot([[0.1, 1], [0.15, 0], [0.2, 1], [0.3, 0], [0.5, 1]]))``` ### Example 2

We demonstrate the difference between linear and cubic spline interpolation:

```plot(plot::Listplot([10, 0, 20, 0, 30], Color = RGB::Red, InterpolationStyle = Linear), plot::Listplot([10, 0, 20, 0, 30], Color = RGB::Blue, InterpolationStyle = Cubic))``` We smoothen the cubic spline curve by increasing the `Submesh` value:

```plot(plot::Listplot([10, 0, 20, 0, 30], Color = RGB::Red, InterpolationStyle = Linear), plot::Listplot([10, 0, 20, 0, 30], Color = RGB::Blue, InterpolationStyle = Cubic, Submesh = 12))``` ### Example 3

A random variable describing the number of successes in n Bernoulli trials with success probability p is binomially distributed with expectation value np and variance np (1 - p). For large values of n, the binomial distribution is approximated by a corresponding normal distribution.

We use `plot::Listplot` to visualize the discrete probability values of the binomial distribution. The normal distribution is visualized via `plot::Function2d`:

```n := 10: p:= 0.4: plot(plot::Listplot([stats::binomialPF(n, p)(i) \$ i = 0..n], x = 0..n, Color = RGB::Red), plot::Function2d(stats::normalPDF(n*p, n*p*(1 - p))(x), x = 0..n, Color = RGB::Blue)):``` `delete n, p:`

## Parameters

 `y1, y2, …` Vertical coordinates: numerical values or expressions of the animation parameter `a`. `y1`, `y2`, … is equivalent to the attribute `Data`. `x` Name of the horizontal coordinate: an identifier or an indexed identifier. It is used as the title of the coordinate axis in x direction. `x` is equivalent to the attribute `XName`. `xmin .. xmax` The range of the horizontal coordinate: `xmin`, `xmax` must be numerical real value or expressions of the animation parameter `a`. `xmin` .. `xmax` is equivalent to the attributes `XRange`, `XMin`, `XMax`. `A1` A 1-dimensional array of domain type `DOM_ARRAY` or a matrix of category `Cat::Matrix` (e.g., of type `matrix` or `densematrix`) with 1 row or 1 column. The entries must be numerical real values or arithmetical expressions of the animation parameter `a`. The entries in `A1` are regarded as data values [y1, y2] etc.. `A1` is equivalent to the attribute `Data`. `x1, x2, …` Horizontal coordinates: numerical values or expressions of the animation parameter `a`. `A2` A 2-dimensional array of domain type `DOM_ARRAY` or a matrix of category `Cat::Matrix` (e.g., of type `matrix` or `densematrix`) with at least two rows and two columns. The entries must be numerical real values or arithmetical expressions of the animation parameter `a`. The i-th row is regarded as the data point (xi, yi). If more than 2 columns are provided, only the data in the first two columns are considered; all additional columns are ignored. `A2` is equivalent to the attribute `Data`. `a` Animation parameter, specified as `a```` = amin..amax```, where `amin` is the initial parameter value, and `amax` is the final parameter value.