# plotHistP#

## Purpose#

Computes and graphs a percent frequency histogram of a vector. The percentages in each category are plotted.

## Format#

plotHistP([myPlot, ]x, v)#
Parameters:
• myPlot (struct) – Optional argument, a `plotControl` structure

• x (Mx1 vector) – data

• v (Nx1 vector or scalar) –

Type

Value

vector

the breakpoints to be used to compute the frequencies.

scalar

the number of categories.

## Examples#

### Basic example with specified number of bins#

```// Simulate random normal data to plot
X = rndn(100, 1);

// Number of bins to create
nbins = 30;

// Draw histogram with default settings
plotHistP(X, nbins);
```

### Basic example with specified bin breakpoints#

```// Simulate random normal data to plot
X = rndn(100, 1);

// Specify bin breakpoints
brk_pts = { -3, -2, -1, 0, 1, 2, 3 };

// Draw histogram with default settings
plotHistP(X, brk_pts);
```

### Control plot settings with plotControl structure#

```// Simulate random normal data to plot
X = rndn(100, 1);

// Number of bins to create
nbins = 30;

// Declare 'myPlot' to be a plotControl structure
// and fill with bar/hist default settings
struct plotControl myPlot;
myPlot = plotGetDefaults("bar");

// Change Histogram fill settings
fill_type = 1;
opacity_pct = 0.8;
fill_clr = "light blue";
plotSetFill(&myPlot, fill_type, opacity_pct, fill_clr);

// Draw histogram with settings stored in 'myPlot'
plotHistP(myPlot, X, nbins);
```