bar#

Purpose#

Generates a bar graph.

Note

This function is for the deprecated PQG graphics, use plotBar() instead.

Library#

pgraph

Format#

bar(val, ht)#
Parameters:
  • val (Nx1 numeric vector) – bar labels. If scalar 0, a sequence from 1 to rows(ht) will be created.

  • ht (NxK numeric vector) – bar heights.

Global Input#

_pbarwid#

scalar, width and type of bars in bar graphs and histograms. The valid range is 0-1. If this is 0, the bars will be a single pixel wide. If this is 1, the bars will touch each other.

If this value is positive, the bars will overlap. If negative, the bars will be plotted side-by-side. The default is 0.5.

_pbartyp#

Kx2 matrix. The first column controls the bar shading:

0

no shading.

1

dots.

2

vertical cross-hatch.

3

diagonal lines with positive slope.

4

diagonal lines with negative slope.

5

diagonal cross-hatch.

6

solid

The second column controls the bar color.

Examples#

In this example, three overlapping sets of bars will be created. The three heights for the ith bar are stored in x[i,.].

library pgraph;
graphset;

t = seqa(0, 1, 10);
x =(t^2/2).*(1~0.7~0.3);

_plegctl = { 1 4 };
_plegstr = "Accnt #1\000Accnt #2\000Accnt #3";
title("Theoretical Savings Balance");
xlabel("Years");
ylabel("Dollars x 1000");

// Set color of the bars
_pbartyp = { 1 10 };
_pnum = 2;

// Use t vector to label x-axis.
bar(t, x);

Remarks#

Use scale() or ytics() to fix the scaling for the bar heights.

Source#

pbar.src

See also

Functions asclabel(), xy(), logx(), logy(), loglog(), scale(), hist()