Object Reference : Graph Creation Commands
Display a bar graph.
(Note: when the individual bars in a bar graph become too thin to be distinguished, the graph will automatically be converted into an area graph; see area.)
bar(options) o1 [o2 o3 ... ]
object_name.bar(options) [categorical_spec(arg)]
where o1, o2, ..., are series or group objects. Following the bar keyword, you may specify general graph characteristics using options. Available options include multiple graph handling, dual scaling, template application, data contraction, adding axis extensions, and rotation.
The optional categorical_spec allows you to specify a categorical graph (see “Categorical Spec”).
Scale options
a (default)
Automatic single scale.
Dual scaling with no crossing. The first series or column is scaled on the left and all other series or columns are scaled on the right.
Dual scaling with possible crossing. See the “d” option.
Normalized scale (zero mean and unit standard deviation). May not be used with the “s” option.
Rotate the graph so the observation axis is on the left.
Add axis border along data scale, where type may be “hist” or “h” (histogram), “boxplot” or “b”, “kernel” or “k”.
(Note: axis borders are not available for panel graphs with “panel=” options that involve summaries: mean, median, etc.)
Multiple series options (categorical graph settings will override these options)
Plot bars in multiple graphs (will override the “s” option).
Stacked bar graph. Each bar represents the cumulative total of the series or columns listed. The difference between bars corresponds to the value of a series or column.
Template and printing options
Use appearance options from the specified template. template may be a predefined template keyword (“default” - current global defaults, “classic”, “modern”, “reverse”, “midnight”, “spartan”, “monochrome”) or a graph in the workfile.
Use appearance options and copy text and shading from the specified graph.
b / -b
[Apply / Remove] bold modifiers of the base template style specified using the “o=” option above.
w / -w
[Apply / Remove] wide modifiers of the base template style specified using the “o=” option above.
Resets all graph options to the global defaults. May be used to remove existing customization of the graph.
Print the graph.
The options which support the “–” may be preceded by a “+” or “–” indicating whether to turn on or off the option. The “+” is optional.
Graph data options
The following option is available in non-panel or categorical graph settings:
Contract the data as specified by key, where key may be: “mean”, “median”, “max”, “min”, “sum”, “var” - variance, “sd” - standard deviation, “sumsq” - sum of the squared values, “skew” - skewness, “kurt” - kurtosis, “nas” - number of missing values, “obs” - number of observations, “unique” - error if the series is not identical for all observations in a given group, “first” - first observation in category using workfile order, “last” - last observation in category using workfile order, “quant(quantile)” - where quantile is a number between 0 and 1.
Panel options
The following option applies when graphing panel structured data:
panel=arg (default taken from global settings)
Panel data display: “stack” (stack the cross-sections), “individual” or “i” (separate graph for each cross-section), “combine” or “c” (combine cross-section graphs in a single frame), “mean” (plot means across cross-sections), “median” (plot median across cross-sections).
(Note: more general versions of these panel graphs may be constructed as categorical graphs.)
Categorical graph options
These options only apply to categorical graphs ( “Categorical Spec”) where the graph has one or more within factors and a contraction method other than raw data (see the contract option above).
Favor the use of legends over axis labels to describe categories.
elemcommon = int
Specifies the number of within factors for which the graph uses common area colors. For example, with multiple within dimensions, if “elemcommon=1”, then only categories defined by the first within factor will have common colors. If “elemcommon=2”, then categories defined by the first two within factors will have common colors. If “elemcommon=0”, all areas will have different colors.
The default is one less than the number of within factors.
Basic examples
bar(p,rotate) oldsales newsales
displays and prints a rotated bar graph of the series OLDSALES and NEWSALES.
displays a bar graph of the series POP.
group mygrp oldsales newsales
displays a stacked bar graph view of the series in the group MYGRP.
mygrp.bar(l, x, o=mybar1)
plots a bar graph of OLDSALES together with a line graph of NEWSALES. The bar graph is scaled on the left, while the line graph is scaled on the right. The graph uses options from graph MYBAR1 as a template.
mygrp.bar(o=midnight, b)
creates a bar graph of MYGRP, using the settings of the predefined template “midnight,” applying the bold modifier.
mygrp.bar(rotate, contract=mean)
displays a rotated bar graph of the means of OLDSALES and NEWSALES.
Panel examples
displays bar graphs for each cross-section in a separate frame, while,
displays a bar graph of the medians of SER1 computed for each period across cross-sections.
Categorical spec examples
ser1.bar across(firm, dispname)
displays a categorical bar graph of SER1 using distinct values of FIRM to define the categories, and displaying the resulting graphs in multiple frames.
ser1.bar across(firm, dispname, iscale)
shows the same graph with individual scaling for each of the frames.
ser1.bar within(contract=mean, firm, inctot, label=value)
displays a graph of mean values of SER1 categorized by firm (along with an added category for the total), with all of the graphs in a single frame and the FIRM category value used as labels.
ser1.bar(contract=sum) across(firm, dispname) within(income, bintype=quant, bincount=4)
constructs a categorical bar graph of the sum of SER1 values within a category. Different firms are displayed in different graph frames, using the display name as labels, with each frame containing bars depicting the sum of SER1 for each income quartiles.
ser1.bar(contract=mean, elemcommon=1) within(sex) within(union)
creates a bar graph of mean values of within categories based on both SEX and UNION. Categories for the distinct elements of UNION will be depicted using different bar colors, with the color assignment repeated for different values of SEX.
group mygrp oldsales newsales
mygrp.bar(contract=min) within(@series) within(age)
displays bar graphs of the minimum values for categories defined by distinct values of AGE (and the two series). All of the bars will be displayed in a single frame with the bars for OLDSALES grouped together followed by the bars for NEWSALES.
mygrp.bar(contract=median, elemcommon=2) across(firm) across(@series) across(age)
also adds an additional categorization using the FIRM identifiers. The observations for a given firm are grouped together. Within a firm, the bars for the OLDSALES and NEWSALES, which will be depicted using different colors, will be grouped within each age category. The color assignment to OLDSALES and NEWSALES will be repeated across firms and ages (note that @SERIES is treated as the last across factor).
See “Graphing Data” for a detailed discussion of graphs in EViews, and “Templates” for a discussion of graph templates.
See Graph::graphfor graph declaration and other graph types.
You may assign labels to the bars in (frozen) graph objects using the Graph::options command