Contents Previous Next Subchapters

Plotting A Bar Graph With Uniform Width Bars
Syntax bar(y)
bar(xy)
See Also gbar , ghist , gstair

Description
Plots a bar graph, where the integer, real, or double-precision vector y specifies the height of each of the bars and the vector x specifies the horizontal location of each of the bars. If m is the length of both the vectors y and x, a bar of height y(i) is plotted centered over the horizontal location x(i) for i equal 1 to m.

If x is not present, the value y(i) is plotted over the horizontal location i. The vector x must be strictly monotone increasing or decreasing.

Example
     clear
     gtitle("Bar Plot of x^2") 
     x = seq(5)
     y = x^2
     bar(x, y)

returns the following plot: