Accelerating the pace of engineering and science

# plotFrontier

Class: Portfolio

Plot efficient frontier

## Syntax

[prsk,pret] = plotFrontier(obj)
[prsk,pret] = plotFrontier(obj,varargin)

## Description

[prsk,pret] = plotFrontier(obj) plots the efficient frontier.

[prsk,pret] = plotFrontier(obj,varargin) plots the efficient frontier with multiple types of input methods. There are four ways to use plotFrontier:

• Method 1 — Given a Portfolio object obj, estimate the efficient frontier with default number of 10 portfolios on the frontier.

• Method 2 — Given a Portfolio object obj, estimate the efficient frontier with a specified number of portfolios NumPorts on the frontier.

• Method 3 — Given a Portfolio object obj with estimated efficient portfolios in PortWeights, plot the efficient frontier with those portfolios. This method assumes that you provide valid efficient portfolios as input.

• Method 4 — Given a Portfolio object obj with estimated portfolio risks (PortRisk) and returns (PortReturn), plot the efficient frontier. This method assumes that you provide valid inputs for efficient portfolio risks and returns.

 Note:   plotFrontier handles multiple input formats as described above. Given an asset universe with NumAssets assets and an efficient frontier with NumPorts portfolios, remember that portfolio weights are NumAsset-by-NumPorts matrices and that portfolio risks and returns are NumPorts column vectors.

## Tips

You can also use dot notation to plot the efficient frontier.

`[prsk, pret] = obj.plotFrontier;`

## Input Arguments

 obj Portfolio object [Portfolio]. varargin (Optional) varargin can be NumPorts, PortRisk, PortReturn, or PortWeights depending on which of the four input methods you use:Method 1 — Given a Portfolio object obj, estimate the efficient frontier with the default number of 10 portfolios on the frontier:`[prsk, pret] = plotFrontier(obj)` Method 2 — Given a Portfolio object obj, estimate the efficient frontier with a specified number of portfolios NumPorts on the frontier: `[prsk, pret] = plotFrontier(obj, NumPorts)`Method 3 — Given a Portfolio object obj with estimated efficient portfolios in PortWeights, plot the efficient frontier with those portfolios: `[prsk, pret] = plotFrontier(obj, PortWeights)`This method assumes that you provide valid efficient portfolios as inputs.Method 4 — Given a Portfolio object obj with estimated portfolio risks (PortRisk) and returns (PortReturn), plot the efficient frontier:`[prsk, pret] = plotFrontier(obj, PortRisk,PortReturn)`This method assumes that you provide valid efficient portfolio risks and returns as inputs.

## Output Arguments

 prsk Estimated efficient portfolio risks (standard deviation of returns).
 pret Estimated efficient portfolio returns.
 Note:   If the Portfolio object has a name in the Name property, the name is displayed as the title of the plot. Otherwise, the plot is just labeled "Efficient Frontier." If the Portfolio object has an initial portfolio in the InitPort property, the initial portfolio is plotted and labeled. If portfolio risks and returns are inputs, make sure that risks come first in the calling sequence. In addition, if portfolio risks and returns are not sorted in ascending order, this method performs the sort. On output, the sorted moments are returned.

## Attributes

 Access public Static false Hidden false

To learn about attributes of methods, see Method Attributes in the MATLAB® Object-Oriented Programming documentation.

## Examples

expand all

### Plot the Efficient Frontier for the Portfolio Object

Given a portfolio p, plot the efficient frontier.

```load CAPMuniverse

p = Portfolio('AssetList',Assets(1:12));
p = estimateAssetMoments(p, Data(:,1:12),'missingdata',true);
p = setDefaultConstraints(p);
plotFrontier(p);
```